rabbittemplate常用方法
时间: 2023-04-26 20:04:51 浏览: 184
RabbitTemplate是Spring AMQP提供的一个用于发送和接收消息的类,常用方法包括:
1. convertAndSend:将Java对象转换为消息并发送到指定的Exchange和Routing Key。
2. send:发送消息到指定的Exchange和Routing Key。
3. receiveAndConvert:从指定的Queue接收消息并将其转换为Java对象。
4. convertSendAndReceive:将Java对象转换为消息并发送到指定的Exchange和Routing Key,然后等待接收响应消息并将其转换为Java对象。
5. setExchange:设置Exchange名称。
6. setRoutingKey:设置Routing Key。
7. setReplyTimeout:设置等待响应消息的超时时间。
8. setConfirmCallback:设置消息发送确认回调函数。
9. setReturnCallback:设置消息发送失败回调函数。
10. setChannelTransacted:设置是否开启事务模式。
11. setConnectionFactory:设置连接工厂。
12. setMandatory:设置是否开启强制路由模式。
13. setQueue:设置Queue名称。
14. setReceiveTimeout:设置接收消息的超时时间。
15. setReplyAddress:设置响应消息的地址。
以上是RabbitTemplate常用方法的简要介绍,具体使用方法可以参考Spring AMQP官方文档。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)