时间:2024-9-1 作者:老大夫 分类: RabbitMQ
说明:鉴于仲裁队列的功能,肯定是需要在前面集群的基础上操作!
和仲裁队列绑定的交换机没有特殊,我们还是创建一个direct交换机即可
交换机名称:exchange.quorum.test
队列名称:queue.quorum.test
路由键:routing.key.quorum.test
像使用经典队列一样发送消息、消费消息
public static final String EXCHANGE_QUORUM_TEST = "exchange.quorum.test";
public static final String ROUTING_KEY_QUORUM_TEST = "routing.key.quorum.test";
@Test
public void testSendMessageToQuorum() {
rabbitTemplate.convertAndSend(EXCHANGE_QUORUM_TEST, ROUTING_KEY_QUORUM_TEST, "message test quorum ~~~");
}
public static final String QUEUE_QUORUM_TEST = "queue.quorum.test";
@RabbitListener(queues = {QUEUE_QUORUM_TEST})
public void quorumMessageProcess(String data, Message message, Channel channel) throws IOException {
log.info("消费端:" + data);
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
}
# 停止rabbit应用
rabbitmqctl stop_app
收发消息仍然正常
推荐阅读:
RabbitMQ交换机类型
Operation006-Topics
Operation019-Federation
Operation007-SpringBoot
Operation018-Stream
Operation004-PubSub
Operation008-Confirm01-A-Producer生产者端消息确认机制
Operation012-DelayPlugin
Operation001-Install
Operation020-Shovel
行动消除疑虑