Spring Boot的ActiveMQ配置

我使用ActiveMQ作为嵌入式Spring Boot。 似乎Broker是通过ActiveMQConnectionFactory创建的。 我知道配置代理的方法是使用代理在查询中设置参数。 如下所述: http : //activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html

我想设置一些关于DLQ的function,所以它在destinationPolicy属性中,但属性类型不是简单类型而是复杂类型,如何编写查询参数来禁用DLQ,好吗?

好问题。 用于自动代理创建的vm-transport的属性非常好,但只能达到我认为你已经达到的程度。

我的建议是你通常用XML来定义代理配置,然后在URI中引用这个xml。 目标策略确实是一个复杂的结构,我不知道如何用简单的查询参数定义它们是好主意,即使它是可能的。

vm://localhost?brokerConfig=xbean:activemq.xml 

补充@Petter和@April答案,在相同的解决方案下,但有更完整的样本:

1. Petter解决方案,在connnection factory url导入activemq.xml

的build.gradle

 ext { springBootVersion = "1.5.3.RELEASE" activeMQVersion = "5.14.5" } dependencies { compile("org.springframework.boot:spring-boot-starter-activemq:${springBootVersion}") compile("org.apache.activemq:activemq-broker:${activeMQVersion}") testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") testCompile group: 'org.apache.activemq', name: 'activemq-spring', version: "${activeMQVersion}" testCompile("junit:junit:4.12") } 

SRC /主/资源/ activemq.xml中

        

Config.java

 @EnableJms @SpringBootApplication @EnableAutoConfiguration @Configuration public class Config {} 

application.properties

 spring.activemq.broker-url=vm://broker1?brokerConfig=xbean:activemq.xml 

2. April解决方案,在Spring Configuration中导入activemq.xml

只需删除application.properties然后将@ImportResource("classpath:activemq.xml")条目添加到Config.java

Config.java

 @EnableJms @SpringBootApplication @EnableAutoConfiguration @Configuration @ImportResource("classpath:activemq.xml") public class Config {} 

我有这个问题,并使用弹簧配置文件解决了它。 在我的情况下,我想配置我的经纪人坚持。

我在我的pom中添加了所需的库:包括activemq-broker,activemq-spring,spring-jms(以及在我的情况下,activemq-leveldb-store)。

我的spring xml文件看起来像这样:

           

我在我的一个配置类中注册了spring文件:

 @ImportResource("activemq-spring.xml") 

这样做了。

我首先尝试了xbeans解决方案,但是我因为缺少一些xbeans类而陷入困境,而且我不知道它是版本还是什么。 我正在使用activemq 5.12.1