当前位置:网站首页>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
边栏推荐
- Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
- 推荐系统专题 | MiNet:跨域CTR预测
- Dataframe first performs grouping operation and then combines output
- QML combines qsqltablemodel to dynamically load data MVC "recommended collection"
- CarSim仿真快速入门(十六)—CarSim传感器仿真之ADAS Sensor Objects (2)
- [advanced mathematics] [4] indefinite integral
- [advanced mathematics] [6] differential calculus of multivariate functions
- Stock software development
- Mindspore1.1.1 source code compilation and installation -- errors in the core compilation stage
- wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
猜你喜欢

Remote monitoring solution of intelligent electronic boundary stake Nature Reserve

Distributed link logging minbox logging usage document
![[advanced mathematics] [1] function, limit, continuity](/img/c5/f9fd3814a61d0fba24b37253c7e51c.png)
[advanced mathematics] [1] function, limit, continuity

9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence

Why did I choose to become a network engineer after graduating from weak current for 3 months

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

Jmeter——接口测试

"Share" devaxpress asp Net v22.1 latest version system environment configuration requirements

「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求

导电滑环在机械设备方面的应用
随机推荐
毕业从事弱电3个月,我为什么会选择转行网络工程师
When AI encounters life and health, Huawei cloud builds three bridges for them
Prescan quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks
Docker builds redis cluster
Remote monitoring solution of intelligent electronic boundary stake Nature Reserve
LP dual currency pledge liquidity mining DAPP system development logic analysis
【高等数学】【1】函数、极限、连续
【高等数学】【3】微分中值定理与导数的应用
RF、GBDT、XGboost特征选择方法「建议收藏」
每条你收藏的资讯背后,都离不开TA
Export and call of onnx file of pytorch model
4、Nacos 配置中心源码解析之 服务端启动
Mindspore1.1.1 source code compilation and installation -- errors in the core compilation stage
PyTorch 模型 onnx 文件的导出和调用
Log in to Baidu online disk with cookies (websites use cookies)
PMP adopts the latest exam outline, here is [agile project management]
Array of sword finger offer question bank summary (I) (C language version)
Interpretation of repartitioned network structure in repvgg network [with code]
Rainbow plug-in extension: monitor MySQL based on MySQL exporter
Formatdatetime explanation [easy to understand]