RabbbitMQ配置mandatory
2022/7/26 23:29:30
本文主要是介绍RabbbitMQ配置mandatory,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
官网文档解释:
If a message is published with the "mandatory" flags set, but cannot be routed, the broker will return it to the sending client (via an AMQP.Basic.Return command).
To be notified of such returns, clients can implement the ReturnListener interface and call Channel.addReturnListener****. If the client has not configured a return listener for a particular channel, then the associated returned messages will be silently dropped.
A return listener will be called, for example, if the client publishes a message with the "mandatory" flag set to an exchange of "direct" type which is not bound to a queue
大意为:开启强制消息投递(mandatory为设置为true),但消息未被路由至任何一个queue,则回退一条消息到生产者,通过配置ReturnListener监听未被路由的消息,如果mandatory为设置为false,那么未被路由选消息将会被丢弃。
channel.addReturnListener(new ReturnListener() { @Override public void handleReturn(int replyCode, String replyText, String exchange, String routingKey, AMQP.BasicProperties properties, byte[] body) throws IOException { } });
RabbitMQ Java Client
这篇关于RabbbitMQ配置mandatory的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-14AutoMQ 携手阿里云共同发布新一代云原生 Kafka,帮助得物有效压缩 85% Kafka 云支出!
- 2024-02-22kafka partitioner
- 2024-01-24AutoMQ生态集成 - 将数据从 AutoMQ Kafka 导入 RisingWave 数据库
- 2024-01-13消息队列面试题:为什么要使用消息队列?
- 2024-01-08"基于 XHAMQ 的消息队列系统实现"
- 2023-11-24全网最全图解Kafka适用场景
- 2023-09-19RabbitMQ 消息应答
- 2023-09-18Flink Sink Kafka 和 Flink 端到端一致性建议
- 2023-07-18【RabbitMQ】当队列中消息数量超过最大长度的淘汰策略
- 2023-07-13【后端面经-架构】RabbitMQ简介