RabbitMQ study notes 6 (XiaoDi Classroom) routing, topic mode

 Let's modify our producer code:

 Let's modify our consumer:

First node:

We have to create some more nodes:

 

Here we only bind one switch queue to the second node.

 Let's start the consumer and producer separately:

We can see that the first switch is only bound to one routing key, and the second switch is bound to three codes that match ours.

In this way, we can allocate the message to the specified path for sending. 

topic topic wildcards and application scenarios

 

 

Let's change our producer code first:

Then we go to modify our consumer code:

 

With node 1, we also need to copy a node 2.

 

Node 2 can copy the code of node 1. We only need to change the log to all log levels.

 Let's run it to see the effect:

Guess you like

Origin blog.csdn.net/weixin_52618349/article/details/131355183