当前位置:网站首页>Fanoutexchange switch code tutorial
Fanoutexchange switch code tutorial
2022-07-25 20:21:00 【Max Heng】
The source code is at the end of the article
1. stay consumer Service statement Exchange、Queue、Binding
@Configuration
public class FanoutConfig {
@Bean
public FanoutExchange fanoutExchange(){
// Statement FanoutExchange Switch
return new FanoutExchange(" Statement FanoutExchange Switch ");
}
// Declare the first queue
@Bean
public Queue fanoutQueue1(){
return new Queue("fanout.queue1");
}
// Bind queue 1 And switches ( The name and type should be consistent , It will be injected according to this )
@Bean
public Binding bindingQueue1(Queue fanoutQueue1, FanoutExchange fanoutExchange){
return BindingBuilder.bind(fanoutQueue1).to(fanoutExchange);
}
// Declare a second queue
@Bean
public Queue fanoutQueue2(){
return new Queue("fanout.queue2");
}
// Bind queue 2 And switches
@Bean
public Binding bindingQueue2(Queue fanoutQueue2, FanoutExchange fanoutExchange){
return BindingBuilder.bind(fanoutQueue2).to(fanoutExchange);
}
}2. stay consumer Service statement two consumers
@RabbitListener(queues = "fanout.queue1")
public void listenFanoutQueue1(String msg){
System.out.println(" Consumers receive fanout.queue1 The news of :【" + msg + "】");
}
@RabbitListener(queues = "fanout.queue2")
public void listenFanoutQueue2(String msg){
System.out.println(" Consumers receive fanout.queue2 The news of :【" + msg + "】");
}3. Finally, start sending message test
@Test
public void testSendFanoutExchange() {
// Switch name
String exchangeName = " Statement FanoutExchange Switch ";
// news
String message = " test FanoutExchange Switch , Please accept !";
rabbitTemplate.convertAndSend(exchangeName, "", message);
} Finally, the running result is 
Source project address :
link : https://pan.baidu.com/s/1vnYVEPGO8B5XLCf9Xc67cA Extraction code : few9
边栏推荐
- [today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
- LP dual currency pledge liquidity mining DAPP system development logic analysis
- How to set tiktok mobile network environment? How can tiktok break the playback volume?
- Myormframeworkjdbc review and problem analysis of user-defined persistence layer framework, and thought analysis of user-defined persistence layer framework
- Stock software development
- Recommendations on how to install plug-ins and baby plug-ins in idea
- [Infographics Show] 248 Public Domain Name
- 4everland storage node portal network design
- The use of new promise, async and await in the project, and the practical application of promise.all in the project
- Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
猜你喜欢
![[advanced mathematics] [1] function, limit, continuity](/img/c5/f9fd3814a61d0fba24b37253c7e51c.png)
[advanced mathematics] [1] function, limit, continuity

UNET and mask RCNN
![MySQL date [plus sign / +] condition filtering problem](/img/86/aed048e27b3e0b0baa919204bc067c.png)
MySQL date [plus sign / +] condition filtering problem

MySQL 日期【加号/+】条件筛选问题

Working principle of radar water level gauge and precautions for installation and maintenance

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac

Difference Between Accuracy and Precision

PyTorch 模型 onnx 文件的导出和调用

【高等数学】【8】微分方程

Network protocol: TCP part2
随机推荐
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
【高等数学】【6】多元函数微分学
Web crawler principle analysis "suggestions collection"
【高等数学】【3】微分中值定理与导数的应用
wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
Cloud native guide: what is cloud native infrastructure
Why did I choose to become a network engineer after graduating from weak current for 3 months
MySQL 日期【加号/+】条件筛选问题
谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
JVM (XXIII) -- JVM runtime parameters
[noi simulation] string matching (suffix automata Sam, Mo team, block)
「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
Working principle of radar water level gauge and precautions for installation and maintenance
Chapter VI modified specification (SPEC) class
Recommended books | essentials of industrial digital transformation: methods and Practice
qml 结合 QSqlTableModel 动态加载数据 MVC「建议收藏」
Log in to Baidu online disk with cookies (websites use cookies)
【高等数学】【8】微分方程
Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
股票软件开发