论坛首页 Java企业应用论坛

spring2+activemq5+jencks2.1,JCAContainer不能自动重连么?

浏览 2642 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-09-23  
   为什么重启ActiveMQ后,监听器不能工作了,只有重启应用,消息才能被监听处理?为什么org.jencks.JCAContainer不能像DefaultMessageListener一样自动重连啊?
<?xml version="1.0" encoding="UTF-8"?>

<beans
  xmlns="http://www.springframework.org/schema/beans"
  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-2.0.xsd">

    <bean id="connectionFactory"
        class="org.apache.activemq.spring.ActiveMQConnectionFactory">
		<property name="brokerURL" value="tcp://195.2.199.9:61616"/>
		<property name="useAsyncSend" value="true"/>
   	</bean>

    <!-- 消息队列监听者(MDP) -->
    <bean id="queueMsgListener" class="com.cdmcs.oa.jms.MagMessageListener"/>
	<!-- 消息主题监听者(MDP) -->
    <bean id="topicMsgListener" class="com.cdmcs.oa.jms.MagTopicMsgListener"/>
	
	<bean id="jmsTransactionManager"  
        class="org.jencks.factory.TransactionManagerFactoryBean"/>
	
	<!--监听容器-->
	<bean id="jencks" class="org.jencks.JCAContainer">
        <property name="bootstrapContext">   
            <bean id="bootstrapContext" class="org.jencks.factory.BootstrapContextFactoryBean">   
				<property name="transactionManager" ref="jmsTransactionManager"/>
                <property name="threadPoolSize" value="25"/>
            </bean>
        </property>
           
        <property name="resourceAdapter">
            <bean id="activeMQResourceAdapter"  
                class="org.apache.activemq.ra.ActiveMQResourceAdapter">   
                <property name="serverUrl"  
                    value="tcp://195.2.199.9:61616"/> 
            </bean>
        </property>
    </bean>   
	
	<!--队列监听:消费队列消息-->
	<bean id="queueListener" class="org.jencks.JCAConnector">   
        <property name="jcaContainer" ref="jencks"/>
        <property name="activationSpec">
            <bean   
                class="org.apache.activemq.ra.ActiveMQActivationSpec">
                <property name="destination" value="my.queue"/> 
                <property name="destinationType"  
                    value="javax.jms.Queue"/> 
            </bean>   
        </property>   
        <property name="ref" value="queueMsgListener"/> <!--队列监听器-->
    </bean>  
	
	<!--主题监听:消费主题消息-->
	<bean id="topicListener" class="org.jencks.JCAConnector">   
        <property name="jcaContainer" ref="jencks"/>   
        <property name="activationSpec">
            <bean   
                class="org.apache.activemq.ra.ActiveMQActivationSpec">
                <property name="destination" value="my.topic"/> 
                <property name="destinationType" value="javax.jms.Topic"/>
                <!--持久订阅配置-->
                <property name="clientId" value="clientId_003"/>
		        <property name="subscriptionName" value="clientId_003"/>
		        <property name="subscriptionDurability" value="Durable"/>
            </bean>   
        </property> 
        <property name="ref" value="topicMsgListener"/> <!--主题监听器-->  
    </bean>  
	
    <!--消息发送模板-->
    <bean id="jmsQueueTemplate"
        class="org.springframework.jms.core.JmsTemplate102">
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="messageConverter" ref="simpleConverter"/>
       	<property name="sessionTransacted" value="true"/>
        <property name="receiveTimeout" value="10000"/>
    </bean>
    
    <bean id="jmsTopicTemplate"
        class="org.springframework.jms.core.JmsTemplate102">
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="messageConverter" ref="simpleConverter"/>
        <property name="pubSubDomain" value="true"/>
        <property name="sessionTransacted" value="true"/>
        <property name="receiveTimeout" value="10000"/>
    </bean>

    <bean id="simpleConverter"
        class="org.springframework.jms.support.converter.SimpleMessageConverter" />

</beans>
  • geronimo.rar (139.2 KB)
  • 描述: geronimo-connector-2.0.2.jar geronimo-jta_1.1_spec-1.1.jar geronimo-transaction-2.0.2.jar
  • 下载次数: 46
   发表时间:2008-10-09  
链接URL修改成这样试试
failover://(tcp://195.2.199.9:61616)?initialReconnectDelay=100
0 请登录后投票
   发表时间:2008-10-09  
mariner 写道

链接URL修改成这样试试 failover://(tcp://195.2.199.9:61616)?initialReconnectDelay=100

多谢,这样配置的确可以解决:
<property name="serverUrl" 
                    value="failover://(tcp://195.2.199.9:61616)&amp;maxReconnectDelay=1000"/>
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics