Here you have to keep in mind that rabbitMQ channel is not thread safe. So create a singleton class that will handle all these rabbitmq operations.
Here you have to keep in mind that rabbitMQ channel is not thread safe. So create a singleton class that will handle all these rabbitmq operations like I am writing code sample in SCALA Object QueueManager{ val FACTORY = new ConnectionFactory FACTORY setUsername (RABBITMQ_USERNAME) FACTORY setPassword (RABBITMQ_PASSWORD) FACTORY setVirtualHost (RABBITMQ_VIRTUALHOST) FACTORY setPort (RABBITMQ_PORT) FACTORY setHost (RABBITMQ_HOST) conn = FACTORY. NewConnection var channel: com.rabbitmq.client.
Channel = conn. CreateChannel //here to decare consumer for queue1 channel. ExchangeDeclare(EXCHANGE_NAME, "direct", durable) channel.
QueueDeclare(QUEUE1, durable, false, false, null) channel queueBind (QUEUE1, EXCHANGE_NAME, QUEUE1_ROUTING_KEY) val queue1Consumer = new QueueingConsumer(channel) channel basicConsume (QUEUE1, false, queue1Consumer) //here to decare consumer for queue2 channel. ExchangeDeclare(EXCHANGE_NAME, "direct", durable) channel. QueueDeclare(QUEUE2, durable, false, false, null) channel queueBind (QUEUE2, EXCHANGE_NAME, QUEUE2_ROUTING_KEY) val queue2Consumer = new QueueingConsumer(channel) channel basicConsume (QUEUE2, false, queue2Consumer) //here you should mantion distinct ROUTING key for each queue def addToQueueOne{ channel.
BasicPublish(EXCHANGE_NAME, QUEUE1_ROUTING_KEY, MessageProperties. PERSISTENT_TEXT_PLAIN, obj. GetBytes) } def addToQueueTwo{ channel.
BasicPublish(EXCHANGE_NAME, QUEUE2_ROUTING_KEY, MessageProperties. PERSISTENT_TEXT_PLAIN, obj. GetBytes) } def getFromQueue1:Delivery={ queue1Consumer.
NextDelivery } def getFromQueue2:Delivery={ queue2Consumer. NextDelivery } } I have written a code sample for 2 queues you can add more queues like above........
Thanks for the sample code. I want multiple consumers on the end of specifically one queue. Can multiple consumers subscribe to one queue and if so, how?
– jkndrkn Jan 1 at 4:42 Yes you can declare multiple consumers for a queue. – sagar Jan 3 at 14:13 Code example please? ^_^ – jkndrkn Jan 4 at 16:48.
Getting pub-subscribe is straight forward, I inital had same problems but works well. The project now has some great help pages at rabbitmq.com/getstarted.html RabbitMQ has timeout and a resernt flag which can be used as you see fit. You can also get the workers to be event driven as aposed to checking every 10ms etc.If you need help on this I have a small project at rabbitears.codeplex.com/ which might help slightly.
Thanks for the links. Pub-sub isn't quite what we are after. This example: rabbitmq.Com/tutorial-three-python.
Html describes a fan-out scenario wherein the same message is sent on multiple queues to multiple consumers. We want multiple consumers to compete for the chance to consume a single instance of the message. – jkndrkn Jan 17 at 5:07.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.