整合 Spring Boot

生产端

1、创建生产者 Spring Boot 工程

2、引入 starter

<!-- RabbitMQ 依赖 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-amqp</artifactId>
</dependency>

3、编写 yaml 配置,基本信息配置

4、定义交换机、队列、绑定关系的配置类

5、注入 RabbitTemplate,调用方法,完成消息发送

 

消费端

1、创建消费者 SpringBoot 工程

2、引入 starter

<!-- RabbitMQ 依赖 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-amqp</artifactId>
</dependency>

3、编写 yaml 配置,基本信息配置

4、定义监听类,使用 @RabbitListener 注解完成队列监听

posted @   半条咸鱼  阅读(42)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示