1、整合springboot
SpringBoot使用activeMq
Springboot 整合activeMq,使用@jmsListener
activemq与spring整合,配置消费者监听器设置sessionAcknowledgeMode问题
SpringBoot 整合ActiveMq自动重连
- (1) 添加依赖
<!-- activemq --> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-spring</artifactId> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-pool</artifactId> </dependency> <dependency> <groupId>org.messaginghub</groupId> <artifactId>pooled-jms</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-activemq</artifactId> </dependency>
(2) application.yml
server: port: 8080 #springBoot项目访问端口 spring: activemq: broker-url: tcp://192.168.31.43:61616 #你activeMQ的ip和端口号 user: admin #activeMq账号 password: admin #activeMq密码 queue-name: active.queue #队列名 pool: enabled: true #连接池启动 max-connections: 10 #最大连接数
或者application.properties
#mq spring.activemq.broker-url=tcp://${ACTIVEMQ_HOST}:${ACTIVEMQ_PORT}?jms.prefetchPolicy.queuePrefetch=5 spring.activemq.close-timeout=5000ms spring.activemq.in-memory=false spring.activemq.pool.enabled=true spring.jms.pub-sub-domain=true spring.activemq.pool.max-connections=10 spring.activemq.send-timeout=3000ms
(3) 在SpringBoot的启动类,类上添加注解@EnableJms
2、自定义JmsListenerContainerFactory时,containerFactory字段的理解
自定义JmsListenerContainerFactory时,containerFactory字段的理解