那您能帮我看下这个整体的配置文件有问题吗?我感觉没问题,可是就是监听不到消息
var activemq = {
conf : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["custom/activemq.properties"]
}
},
targetConnectionFactory : {
type : "org.apache.activemq.ActiveMQConnectionFactory",
fields : {
brokerURL : {java:"$conf.get('activemq.url')"},
userName : {java:"$conf.get('activemq.userName')"},
password : {java:"$conf.get('activemq.password')"},
useAsyncSend : "true",
redeliveryPolicy : {
defaultRedeliveryPolicy : {
type : "org.apache.activemq.RedeliveryPolicy",
fields : {
maximumRedeliveries : {java:"10"},
redeliveryDelay : {java:"6000"},
}
}
}
}
},
connectionFactory : {
type : "org.springframework.jms.connection.CachingConnectionFactory",
fields : {
targetConnectionFactory : {refer : 'targetConnectionFactory'},
reconnectOnException : "true",
cacheConsumers : "false",
cacheProducers : "false",
sessionCacheSize : 50,
clientId : "clientId_jgzf",
}
},
consumerSessionAwareMessageListener : {
type : "com.axgt.safety.context.mq.ConsumerSessionAwareMessageListener",
},
backOff : {
type : "org.springframework.util.backoff.ExponentialBackOff",
},
topicDestination : {
type : "org.apache.activemq.command.ActiveMQTopic",
args : [
{java:"$conf.get('activemq.topic')"}
]
},
//消费者
jmsContainer : {
type : "org.springframework.jms.listener.DefaultMessageListenerContainer",
fields : {
connectionFactory : {refer : 'connectionFactory'},
// destination : {refer : 'topicDestination'},
messageListener : {refer : 'consumerSessionAwareMessageListener'},
backOff : {refer : 'backOff'},
autoStartup : {java:"$conf.get('activemq.turnOn')"},
subscriptionDurable : "true",
pubSubDomain : "true",
clientId : "clientId_jgzf",
durableSubscriptionName : "clientId_jgzf"
}
},
};
activemq.url=tcp://10.114.12.63:61616
activemq.queue=zhpt.queue
activemq.userName=system
activemq.password=manager
activemq.topic=BZ.Topic.HB
activemq.turnOn=true
spring.jms.listener.acknowledge-mode=CLIENT
参考下面这段修改的,有没有语法不对的或者嵌套错误的情况?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd">
<bean id="targetConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq.url}"/>
<property name="userName" value="${activemq.userName}"/> <!-- 连接的用户名 -->
<property name="password" value="${activemq.password}"/> <!-- 连接的密码 -->
<property name="useAsyncSend" value="true"/>
<property name="redeliveryPolicy">
<bean name="defaultRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="10"/>
<property name="redeliveryDelay" value="60000"/>
</bean>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<!-- 目标ConnectionFactory对应真实的可以产生JMS Connection的ConnectionFactory -->
<property name="targetConnectionFactory" ref="targetConnectionFactory"/>
<property name="reconnectOnException" value="true"/>
<property name="cacheConsumers" value="false"/>
<property name="cacheProducers" value="false"/>
<property name="sessionCacheSize" value="50"/>
<property name="clientId" value="clientId_jgzf"/>
</bean>
<!-- 消息监听类(实现类),订阅模式 -->
<bean id="bzkListener" class="com.safety.app.mq.BzkListener"></bean>
<bean id="backOff" class="org.springframework.util.backoff.ExponentialBackOff"></bean>
<!-- 这个是队列目的地 -->
<bean id="topicDestination" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="${activemq.bz.topic}" index="0" />
</bean>
<!-- 消息监听容器 -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="topicDestination"/>
<property name="messageListener" ref="bzkListener"/>
<property name="backOff" ref="backOff"/>
<property name="autoStartup" value="${activemq.turnOn}"/>
<!-- <property name="clientId" value="clientId_zhpt"/> -->
<property name="subscriptionDurable" value="true"/>
<property name="pubSubDomain" value="true"/>
<property name="clientId" value="clientId_jgzf"/>
<property name="durableSubscriptionName" value="clientId_jgzf"/>
</bean>
<!-- 定义Queue监听器,点对点消息模式 -->
<!--<jms:listener-container destination-type="queue" container-type="default" connection-factory="connectionFactory">-->
<!--<jms:listener destination="${activemq.queue}" ref="queueReceiver"/>-->
<!--</jms:listener-container>-->
</beans>