Open hmihail opened 9 years ago
Fanout exchange doesn't seem to be a right choice for your case because whatever you publish to the exchange will be routed to those 2 queues. I would suggest you use Direct exchange and use different binding for different queue.
Direct exchange -> routing key = Order -> OrderQueue Direct exchange -> routing key = FinishedOrder -> FinishedOrderQueue.
These 2 messages can be different or from the same class. You can then subscribe to those 2 queues and process messages differently. I think you just need to implement a IRouteFinder and can use it with Burrow.NET.
http://thoai-nguyen.blogspot.com.au/2012/05/rabbitmq-exchange-queue-name-convention.html
Cheers
Thanks! I will try that. But will this setup allow me to listen to FinishedOrdersQueue with more than one subscriber?
What do you really mean by "more than one subscriber"
If you mean multiple threads, Burrow.NET supports that by default, you can specify the number of threads when subscribe to the queue.
If you mean multiple instances of your code on different servers to subscribe to the same queue in order to share the load, then also YES because RabbitMQ allows you to subscribe that way.
Cheers
What I want is to subscribe to the FinishedOrdersQueue with 2 applications, and both to receive each message. I just implemented your suggestion and it works but only one instance of the app gets the message.
Let's say you publish message type "FinishedOrdersQueue" to the exchange and eventually route to that queue. If you subscribe from that queue, your app will receive messages of that type. If there are multiple instances subscribe from that queue, they will receive messages by Round Robin fashion and I'm 100% sure about that. Could you try to puplish messages faster than they are being processed? Or simply stop the instance that is receiving messages to see what happen to the other instance? Also make sure there is not any conectivitiy problem!
Yes, they are balanced between the subscribers, but I don't want that. I want all of the subscribers to get all the messages. Maybe the direct type of the exchange is not the best?
Ah ok, you want all subscribers to have the same amount of messages. Then I guess you can create another queue, bind to the same exchange with the same routing key, each instance then subscribe to different queue.
Try to use ConstantRouteFinder for those subscribers to subscribe to the expected queue. I think you can create the 2nd queue manually and bind it manually
Hi,
I am pretty new with this, so please excuse me if my question is stupid.
I want to implement a publish / subscribe pattern with a class let's call it Order. I want to be able to have 2 subscriptions, based on the Order state, and also to be able to subscribe with more than one instance, and get all the messages, not round-robin them.
I've created an exchange, fanout, and bind two queues to it, one for new Orders and one for finished Orders. No routing key to the bindings.
Is this approach good, because I can't get it to work. Any ideas, maybe an example?
Thanks!