Announcement Announcement Module
Collapse
No announcement yet.
How to config Spring Integration + Active MQ with two server? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to config Spring Integration + Active MQ with two server?

    I would start two Active MQ JMS server, server As brokerURL is tcp://JMLIUA:61616, server Bs brokerURL is tcp://JMLIUB:61616.I user App A send a string message to App B, I get the following exception:
    [task-scheduler-2] ERROR [org.springframework.integration.handler.LoggingHan dler] - org.springframework.integration.message.MessageTim eoutException: failed to receive JMS response within timeout of: 5000ms

    The following is my configuration:
    App A
    common.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:integration="http://www.springframework.org/schema/integration"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
    
    	<bean id="fsCityConnectionFactory"
    		class="org.springframework.jms.connection.CachingConnectionFactory">
    		<property name="targetConnectionFactory">
    			<bean class="org.apache.activemq.ActiveMQConnectionFactory">
    				<property name="brokerURL" value="tcp://JMLIUB:61616" />
    			</bean>
    		</property>
    		<property name="sessionCacheSize" value="10" />
    		<property name="cacheProducers" value="false" />
    	</bean>
    
    	<bean id="fsGaoMingConnectionFactory"
    		class="org.springframework.jms.connection.CachingConnectionFactory">
    		<property name="targetConnectionFactory">
    			<bean
    				class="org.apache.activemq.ActiveMQConnectionFactory">
    				<property name="brokerURL" value="tcp://JMLIUA:61616" />
    			</bean>
    		</property>
    		<property name="sessionCacheSize" value="10" />
    		<property name="cacheProducers" value="false" />
    	</bean>
    
    	<bean id="requestQueue"
    		class="org.apache.activemq.command.ActiveMQQueue">
    		<constructor-arg value="queue.demo" />
    	</bean>
    
    	<bean id="replyQueue"
    		class="org.apache.activemq.command.ActiveMQQueue">
    		<constructor-arg value="queue.reply" />
    	</bean>
    
    	<integration:poller id="poller" default="true">
    		<integration:interval-trigger interval="1000" />
    	</integration:poller>
    </beans>
    ServerA_Gateway.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/integration"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	xmlns:jms="http://www.springframework.org/schema/integration/jms"
    	xmlns:stream="http://www.springframework.org/schema/integration/stream"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/context
    			http://www.springframework.org/schema/context/spring-context-2.5.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
    			http://www.springframework.org/schema/integration/jms
    			http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd
    			http://www.springframework.org/schema/integration/stream
    			http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
    
    	<stream:stdin-channel-adapter id="stdin"
    		channel="stdinToJmsoutChannel" />
    
    	<channel id="stdinToJmsoutChannel" />
    
    	<jms:outbound-gateway id="fsCityOutGateway"
    		request-channel="stdinToJmsoutChannel"
    		request-destination="requestQueue"
    		reply-channel="jmsReplyToStdoutChannel" reply-destination="replyQueue"
    		connection-factory="fsCityConnectionFactory" />
    
    	<channel id="jmsReplyToStdoutChannel" />
    
    	<stream:stdout-channel-adapter channel="jmsReplyToStdoutChannel" append-newline="true" />
    </beans:beans>
    App B
    common.xml
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:integration="http://www.springframework.org/schema/integration"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
    
    	<bean id="fsCityConnectionFactory"
    		class="org.springframework.jms.connection.CachingConnectionFactory">
    		<property name="targetConnectionFactory">
    			<bean
    				class="org.apache.activemq.ActiveMQConnectionFactory">
    				<property name="brokerURL" value="tcp://JMLIUA:61616" />
    			</bean>
    		</property>
    		<property name="sessionCacheSize" value="10" />
    		<property name="cacheProducers" value="false" />
    	</bean>
    
    	<bean id="fsGaoMingConnectionFactory"
    		class="org.springframework.jms.connection.CachingConnectionFactory">
    		<property name="targetConnectionFactory">
    			<bean
    				class="org.apache.activemq.ActiveMQConnectionFactory">
    				<property name="brokerURL" value="tcp://JMLIUB:61616" />
    			</bean>
    		</property>
    		<property name="sessionCacheSize" value="10" />
    		<property name="cacheProducers" value="false" />
    	</bean>
    
    	<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
    		<constructor-arg value="queue.request"/>
    	</bean>
    
    	<bean id="replyQueue" class="org.apache.activemq.command.ActiveMQQueue">
    		<constructor-arg value="queue.reply"/>
    	</bean>
    
    	<integration:poller id="poller" default="true">
    		<integration:interval-trigger interval="1000"/>
    	</integration:poller>
    </beans>
    ServerB_Gateway.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/integration"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:jms="http://www.springframework.org/schema/integration/jms"
    	xmlns:stream="http://www.springframework.org/schema/integration/stream"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/context
    			http://www.springframework.org/schema/context/spring-context-2.5.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
    			http://www.springframework.org/schema/integration/jms
    			http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd
    			http://www.springframework.org/schema/integration/stream
    			http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
    
    	<context:component-scan base-package="SIAMQTest.fsCity" />
    
    	<jms:inbound-gateway id="FSCityGateway"
    		request-destination="requestQueue" request-channel="demoChannel"
    		connection-factory="fsCityConnectionFactory" default-reply-queue-name=""/>
    
    	<channel id="demoChannel" />
    
    	<service-activator input-channel="demoChannel" ref="demoBean" />
    
    	<channel id="demoProcessChannel" />
    
    	<stream:stdout-channel-adapter channel="demoProcessChannel"
    		append-newline="true" />
    </beans:beans>
    Help me out.

    Thanks in advance

    JMLiu
    Last edited by jmliu; Jan 8th, 2010, 07:03 PM.

  • #2
    I get the bug,it's my carelessness.
    App A
    common.xml

    Code:
    <bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
    	<constructor-arg value="queue.demo" />
    </bean>
    should be
    Code:
    <bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
    	<constructor-arg value="queue.request" />
    </bean>

    Comment

    Working...
    X