首先,我在github上找到了一个不错的demo,这里放给大家一起看下:
确实可以实现功能,但是当我在8161默认的admin端口进行queue查询时,发现并没有我们的github-queue,虽然不太清楚具体的原因,但是解决方式倒是找到了,下面贴一下自己的实现:
pox.xml:
- <!-- ActiveMQ -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jms</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-all</artifactId>
- <version>5.13.2</version>
- </dependency>
application.properties:
- spring.activemq.in-memory=true
- spring.activemq.pooled=false
接下来就是jms的配置了,首先是ActiveMQ4Config文件:
- @EnableJms
- @Configuration
- public class ActiveMQ4Config {
- @Bean
- public Queue queue() {
- return new ActiveMQQueue("github-queue");
- }
- @Bean
- public ActiveMQConnectionFactory activeMQConnectionFactory (){
- ActiveMQConnectionFactory activeMQConnectionFactory =
- new ActiveMQConnectionFactory(
- ActiveMQConnectionFactory.DEFAULT_USER,
- ActiveMQConnectionFactory.DEFAULT_PASSWORD,
- // "tcp://192.168.0.100:61616");
- ActiveMQConnectionFactory.DEFAULT_BROKER_URL);
- return activeMQConnectionFactory;
- }
- }
注释掉的那行,可以用来指定activemq的broker地址。
接下来的Producer和Consumer与github上一样:
- @Component
- public class Producer implements CommandLineRunner{
- @Autowired
- private JmsMessagingTemplate jmsMessagingTemplate;
- @Autowired
- private Queue queue;
- @Override
- public void run(String... args) throws Exception {
- send("this message is send on begining!");
- System.out.println("Message was sent to the Queue");
- }
- public void send(String msg) {
- this.jmsMessagingTemplate.convertAndSend(this.queue, msg);
- }
- }
- @Component
- public class Consumer {
- @JmsListener(destination = "github-queue")
- public void receiveQueue(String text) {
- System.out.println(text);
- }
- }
这样一来就完成了配置,而且在8161默认admin进行查询时,是能够查询到我们的github-queue这个队列的。
具体的测试,可以自己进行,这里不再贴测试用例了。
相关推荐
SpringBoot+ActiveMq+MQTT实现消息的发送和接收 后台消费者、生产者、消息发送接口、发送消息业务类等相关配置
微服务架构面试题系列:Dubbo+Spring Boot+Spring Cloud+Nginx+ActiveMQ+RabbitMQ+Kafka
springboot +netty+activeMq在线客服系统springboot +netty+activeMq在线客服系统springboot +netty+activeMq在线客服系统springboot +netty+activeMq在线客服系统springboot +netty+activeMq在线客服系统springboot...
基于Springboot+ActiveMQ事务==本地事件表+activemq,即利用activemq+本地事件表实现分布式事务的功能
springboot整合mybatis+activemq(activemq可以去官网下载
NULL 博文链接:https://yaozhiqiang109.iteye.com/blog/1073455
涵盖的主题Sprint Boot子休息区ApiSpring启动批处理SSL连接JMS(Java消息服务) Swagger UI用于可视化API错误处理基本认证POJO <-> DTO的映射器记录中测验使用DataJpaTest的存储库使用DataMongoTest的存储库使用...
spring boot activemq集成示例,包含queue和topic消息的发送、接收,连接池的支持。
本项目基于Spring boot这一平台,整合流行的开源消息队列中间件ActiveMQ,实现一个向ActiveMQ添加和读取消息的功能。分别实现生产者-消费者模式和发布-订阅模式,作为java编程发送消息和消费消息的基础示例。 源码...
spring boot 集成activemq Datajpa Ehcache 里面有详细的例子
本书围绕秒杀抢购应用场景 ,对当下...主要内容包括微服务架构介绍、 Dub box 原理及运用、使用 Spring Boot实现微服务 使用 ActiveMQ Redis 承载高兴二发流量、使用 ctiveMQ 实现分布式事务 分布式下的 第三方接入等。
SpringBoot整合ActiveMQ+websocket.docx ,该文档包含于activemq整合的各个情况,springboot,js,websocket与mq整合,该资源是上传代码的word文档部分
分布式通讯面试专题系列:ActiveMQ+RabbitMQ+Kafka 分布式限流面试专题系列:Nginx+zookeeper 开源框架面试题系列:Spring+SpringMVC+MyBatis 面试必问并发编程高级面试专题 面试常问必备之MySQL面试55题 微服务架构...
spring boot ActiveMQ学习练习demo项目源码;包含text,map,byte,stream,object5种类型信息的发送和接收
整合了spring,mybatis,hibernate,activemq,redis,dubbo的一个工程,项目管理工具是maven,数据库用的mysql。
Spring boot 和内置ActiveMQ集成例子,通过代码学习Spring boot 和内置ActiveMQ集成。
Spring Boot 做的一个简单的增删改查,前台页面整合Thymeleaf模板,数据源druid,声明式事务,整合redis,并开启redis事务,整合ActiveMQ
Nepxion Thunder是一款基于Netty + Hessian + Kafka + ActiveMQ + Tibco + Zookeeper(Curator Framework) + Redis + FST + Spring + Spring Web MVC + Spring Boot + Docker分布式RPC调用框架。架构思想主要是来自...
分布式通讯面试专题系列:ActiveMQ+RabbitMQ+Kafka 分布式限流面试专题系列:Nginx+zookeeper 开源框架面试题系列:Spring+SpringMVC+MyBatis 微服务架构面试专题系列:Dubbo+Spring Boot+Spring Cloud 性能优化面试...
ActiveMQ+RabbitMQ+Kafka、分布式限流面试专题系列:Nginx+zookeeper、集合、开源框架面试题系列:Spring+SpringMVC+MyBatis、23种设计模式知识要点整理、Dubbo、Dubbo服务框架面试专题及答案整理文档、java筑基...