1.声明
当前内容主要为使用SpringBoot操作Linux下的ActiveMQ(5.16.1版本),主要用于记录操作!
当前demo类似:SpringBoot中简单的使用ActiveMQ实现发送和处理消息,的内容
2.差异
1.由于版本不同,所以pom文件也不同:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.18.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.16.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.16.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-openwire-legacy</artifactId>
<version>5.16.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.16.1</version>
</dependency>
</dependencies>
其中的版本为5.16.1版本
2.由于远程连接Linux中的ActiveMQ所以application.properties中的内容不同!
spring.activemq.broker-url=tcp://192.168.1.100:61616
spring.activemq.user=admin
spring.activemq.password=admin
其中小心spring.activemq.broker-url
的指定端口必须为:61616
3.其他的配置、controller都完全一致
3.测试
1.启动后发现会自动创建myQueue这个队列
2.使用localhost:8080/send?msg=你好
发送消息
3.使用ui方式发送消息:
点击send To
填写发送的目的地,并选择类别为Queue,填写内容然后发送
4.总结
1.一定要小心当前的spring.activemq.broker-url=tcp://192.168.1.100:61616
,端口为61616
2.可以通过web方式发送数据,感觉比RabbitMQ不一样,ActiveMQ有两种一个为Topic和Queue这个也和RabbitMQ不一样
3.RabbitMQ中发送消息需要binding才可以通过路由交换方式发送数据
,这个ActiveMQ比较单一