RabbitMq

Posted duanmy0687

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RabbitMq相关的知识,希望对你有一定的参考价值。

TopicExchange 用消息的routingKey与Exchange和queue间binding-key进行模糊*或者#模式匹配
DirectExchange 用消息的routingKey与Exchange和queue间的binding-key进行完全匹配
CustomerExchange
FanoutExchange 订阅模式,与 routingKey和binding-key无关,将消息发给所有绑定关系的所有队列

  • 生产者
rabbitTemplate.convertAndSend(exchange, routingKey,object)
rabbitTemplate.convertAndSend(
“scf.loan.warehouse.common.notice.exchange”, 
“scf.loan.warehouse.common.notice.key”,
msgMap)
  • 配置类
@Bean
Public Queue wrCommonNoticeQueue()
 Queue queue=new Queue(“scf.loan.warehouse.common.notice.queue”);
 Return queue;

@Bean
Public TopicExchange wrCommonNoticeExchange()
 Return new TopicExchange(“scf.loan.warehouse.common.notice.exchange”)

Return BindingBuilder.bind(Queue).to(TopicExchange).with(routingKey)
@Bean
Public Binding wrCommonNoticeBingding(Queue wrCommonNoticeQueue, TopicExchange wrCommonNoticeExchange)
 Return BindingBuilder.bind(wrCommonNoticeQueue).to(wrCommonNoticeExchange).with(scf.loan.warehouse.common.notice.key)

  • 消费者(监听)
@RabbitListener(queues=”scf.loan.warehouse.common.notice.queue”)
Public void listener(Map<String, Object> msg)
String busTraNo=(String) msp.get(“busTraNo”);
Object sendBean=msg.get(“sendBean”);
...

以上是关于RabbitMq的主要内容,如果未能解决你的问题,请参考以下文章

RabbitMQRabbitMQ和Erlang下载与安装步骤—2023超详细最新版

Springboot 整合 RabbitMQrabbitmq介绍:安装,下载,创建队列交换机,5种工作模式

Java面试题

RabbitMQ

Java复习--Redis

Java复习--Redis