使用Spring Boot进行ActiveMQ配置 [英] ActiveMQ configuration with Spring Boot
问题描述
我将ActiveMQ与Spring Boot一起使用。
似乎是通过ActiveMQConnectionFactory创建的Broker。
我知道配置代理的方法是在查询中使用代理设置参数。如此处所述: http://activemq.apache.org/我如何在经纪人内部嵌入a-connection.html
I use ActiveMQ as Embedded with Spring Boot. It seems the Broker is created trough an ActiveMQConnectionFactory. I understand that the way to configure the broker is to set parameters in the query with broker. as described here : http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
我想设置有关DLQ的某些功能,因此它位于destinationPolicy属性中,但是该属性类型不是简单类型而是复杂类型,请问如何编写查询参数以禁用DLQ?
I would like to setup some features about the DLQ, so it's in the destinationPolicy attribute, but the attribute type is not a simple type but a complex type, how can I write the query parameter to disable DLQ, please ?
推荐答案
在相同的解决方案下补充@Petter和@April答案,但具有更完整的示例:
Complementing @Petter and @April answers, below the same solutions but with more complete samples:
1。 Petter解决方案,在连接工厂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 / main / resources / activemq.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.4.0.xsd
">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1" persistent="false" >
<transportConnectors>
<transportConnector name="vm" uri="vm://broker1"/>
</transportConnectors>
</broker>
</beans>
Config.java
@EnableJms
@SpringBootApplication
@EnableAutoConfiguration
@Configuration
public class Config {}
application.properties
spring.activemq.broker-url=vm://broker1?brokerConfig=xbean:activemq.xml
2。四月的解决方案,在Spring Configuration中导入activemq.xml
只需删除 application.properties
,然后添加 @ImportResource( classpath:activemq.xml)
条目到 Config.java
Just remove application.properties
then add @ImportResource("classpath:activemq.xml")
entry to Config.java
Config.java
@EnableJms
@SpringBootApplication
@EnableAutoConfiguration
@Configuration
@ImportResource("classpath:activemq.xml")
public class Config {}
这篇关于使用Spring Boot进行ActiveMQ配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!