. Net RabbitMQ operation component EasyNetQ WithTopic filtering failure solution, rabbitmqeasynetq
RabbitMQ principle and Tutorial: http://www.cnblogs.com/AlvinLee/p/6141834.html
What is EasyNetQ and its common usage are not described here. Can refer to this blog: http://blog.csdn.net/hesi9555/article/details/70139346
Here we will talk about a point in the WithTopic method in EasyNetQ that is easy to waste a lot of time.
After using the Subscribe method of EasyNetQ and then using the SubscribeWithTopic method, you may find that no matter what the Routing Key (the third parameter in the SubscribeWithTopic) writes, no matter whether your Routing key is the same or different from the sender's Routing Key, the receiver can all receive it, that is, the WithTopic filter function is invalid. Why?
At this time, as long as you open the queue Panel of the RabbitMQ web management background,
(Http: // localhost: 15672/#/queues. If you cannot open it, right-click the sbin directory of rabbitmq-server to open the command line and run
.\rabbitmq-plugins.bat enable rabbitmq_management
To start the web management background .)
Click the newly created queue and open the bindings drop-down menu. If you see "#" in the Routing key column, it means that all the Routing keys added later are invalid. # Accept all. Each time you run Subscribe, the "#" filter rule is automatically added and set to the top.
Solutions:
1. manually delete the file. "#" Click the unbind button. If Subscribe is used and you want to change it to SubscribeWithTopic, you must manually delete it again.
2. Use the code to delete the file.
Var bus = rabbithuch. CreateBus (connectionString );
IAdvancedBus advancedBus = bus. advanced; IBinding bind = advancedBus. bind (new Exchange ("Model. message: Model (vswitch name) "), new Queue (" Model. message: Model_id1 (queue name) ", false)," # "); advancedBus. bindingDelete (bind );