In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
In the Rabbit-based API, declaring an exchange, declaring a binding, and declaring a queue are all created through channel. As shown below:
So how are these objects declared in spring AMQP?
When using springAMQP to declare, you need to use the following mode of springAMQP. Even with the @ Bean mode:
Let's do a code demonstration:
Modify the RabbitMQConfig class in the previous code. Add as follows:
/ * *
* configuration for consumers
* 1. Set switch type
* 2. Bind the queue to the switch
FanoutExchange: distribute messages to all bound queues, without the concept of routingkey
HeadersExchange: match by adding attribute key-value
DirectExchange: distribute to the specified queue according to routingkey
TopicExchange: multiple keyword matching
, /
Description:
We need to set it up according to different switch characteristics.
Such as topic's:
Start the test code and view the queue:
View the switch:
View the binding relationship:
Take the topic001 switch as an example:
Two queues are bound. Queue 1 and queue 3.routingkey are: spring.* and mq.*. Is it right after all?
Let's look at the code:
You can see that this is indeed the binding in the code. Note that we declare that the queue, binding, and switch are successful.
This article was published on 51CTO by Kaige Java (Java). Official account: Kaige Java (kaigejava). Personal blog: www.kaigejava.com
This section summarizes:
Get exchange, binding, queue objects through bean annotations.
This article is the second Spring AMQP statement in the "rabbitMq intensive series" tutorial: article 19 of the rabbitMQ intensive series on advanced integrated applications. Series of tutorials, it is recommended to start from the first article.
The next section is a preview:
Next class, we will talk about an important object, the rabbitTemplate object.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.