Bạn có chắc chắn muốn xóa bài viết này không ?
Bạn có chắc chắn muốn xóa bình luận này không ?
SpringBoot RabbitMq Headers Exchange
https://grokonez.com/spring-framework/spring-amqp/springboot-rabbitmq-headers-exchange
SpringBoot RabbitMq Headers Exchange
In the past post, we had introduced about RabbitMQ Topic Exchange. Today, JavaSampleApproach will show you how to work with SpringBoot RabbitMQ Headers Exchange.
Related posts:
- SpringBoot RabbitMQ Topic Exchange
- RabbitMQ – How to create Spring RabbitMQ Producer/Consumer applications with SpringBoot
- RabbitMq – How to create Spring RabbitMq Publish/Subcribe pattern with SpringBoot
- RabbitMQ – How to send/receive Java object messages with Spring RabbitMq | SpringBoot
- SpringBoot RabbitMq Exchange to Exchange Topology
I. Technologies
– Java 8
– Maven 3.6.1
– Spring Tool Suite – Version 3.8.1.RELEASE
– Spring Boot: 1.5.7.RELEASE
– RabbitMQ
II. RabbitMq Headers Exchange
Headers exchange routes message based on header values instead of routing keys.
A special argument named x-match
has 2 values {all
, any
} where all
is the default value of a headers binding.
-
x-match
= all means that all the values must match. -
x-match
= any means just one matching header value is sufficient.
Scenarios with above design:
- When sending a message with headers: {
layer=system
,level=error
}, the message will be delivered to 2 queues {Q1, Q2}. - When sending a message with headers: {
layer=application
,level=error
}, the message will be delivered to one queue Q2. - When sending a message with headers: {
layer=system
,level=info
}, the message will be discarded.III. Practices
In the tutorial, we create 2 SpringBoot project as below:
Step to do:
– Create SpringBoot projects
– Implement RabbitMq producer
– Implement RabbitMq consumer
– Run and check results
1. Create SpringBoot projects
Using SpringToolSuite, create 2 SpringBoot projects, then add need dependency spring-boot-starter-amqp
:
https://grokonez.com/spring-framework/spring-amqp/springboot-rabbitmq-headers-exchange
SpringBoot RabbitMq Headers Exchange




