Spring Boot与ActiveMQ的集成

 

1、ActiveMQ软见得安装配置

1.1、上传软件包并解压

Spring Boot与ActiveMQ的集成

 

1.2、配置并启动

Spring Boot与ActiveMQ的集成

 

1.3、浏览器验证

Spring Boot与ActiveMQ的集成

2、添加ActiveMQ起步依赖;

Spring Boot与ActiveMQ的集成

3、创建消息队列对象,在Application.java中编写一个创建消息队列的方法,其代码展示如下;

Spring Boot与ActiveMQ的集成

4、创建消息生产者,创建一个队列消息的控制器类QueueController,并在类中编写发送消息的方法,其代码如下所示;

Spring Boot与ActiveMQ的集成

5、创建消息监听者,创建一个客户控制器类CustomerController,并在类中编写监听和读取消息的方法,其代码如下。

Spring Boot与ActiveMQ的集成

6、启动项目,测试应用;

Spring Boot与ActiveMQ的集成

Spring Boot与ActiveMQ的集成

7、使用外部的ActiveMQ,在指定的配置文件中配置指定ActiveMQ的远程主机地址以及服务端口号,其配置如下:

Spring Boot与ActiveMQ的集成

8、浏览器登录到ActiveMQ中;

Spring Boot与ActiveMQ的集成

9、访问http://localhost:8084/send 执行3次刷新操作后,ActiveMQ管理页面中的队列信息显示如图;

Spring Boot与ActiveMQ的集成

Spring Boot与ActiveMQ的集成