Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Outbound Gateway Dilemma

  1. #1
    Join Date
    Jun 2010
    Posts
    17

    Default Outbound Gateway Dilemma

    I am using a using an outbound gateway in a request/reply scenario. I am able to send one request and receive the reply. Efforts to send a second request results in a MessageTimeoutException.

    The server, using an inbound-gateway, chain and service activator appears to work fine. In fact, the second reply is on the message queue waiting to be read by the client but for some reason the inbound-gateway isn't picking it up.

    I use a ChannelResolver to obtain a MessageChannel which I then use to send a message.

    The fact that I am able to consistently receive the first reply would seem to suggest that the wiring of the components is basically correct.

    Should a be able to use the same message channel to send multiple messages? Is there some setting that is necessary for this scenario to work?

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    Are you talking about JMS gateways? Can you provide some configuration excerpts?

  3. #3
    Join Date
    Jun 2010
    Posts
    17

    Default

    Hi Mark! Yes, I'm using JMS. Here are the configuration elements:

    Server side (inbound-gateway):

    Code:
    <beans:bean id="manager" class="business.Manager"/>
    
    <jms:inbound-gateway id="jmsin" request-destination="some.queue" request-channel="jmsinputchannel"/>
    
    <chain input-channel="jmsinputchannel">
         <transformer id="xml-to-object" ref="marshaller" method="unmarshal" />
         <service-activator ref="manager" method="process" />
         <transformer id="object-to-xml" ref="marshaller" method="marshal" />
    </chain>
    Client side (outbound-gateway):
    Code:
    <gateway id="someService" service-interface="services.SomeService" 
                      default-request-channel="someServiceRequestChannel" 
                      default-reply-channel="someServiceReplyChannel"/>
    
    <channel id="someServiceRequestChannel"/>
    
    <jms:outbound-gateway request-channel="someServiceRequestChannel"
                         request-destination="some.queue"
                         reply-destination="some.other.queue" 
                         reply-channel="someServiceReplyChannel"/>
    
    <channel id="someServiceReplyChannel"/>
    Thanks!
    Edit/Delete Message

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    The problem is in your configuration. You are creating a conflict when pointing to the same channel while defining default-reply-channel on Gateway and reply-channel on OutboundMessageGateway.
    Basically your two Gateway are listening on the same channel.

    Modify your server configuration as follows:
    Code:
    <gateway id="someService" service-interface="services.SomeService" 
                      default-request-channel="someServiceRequestChannel" 
                      default-reply-channel="someServiceReplyChannel"/>
    
    <channel id="someServiceRequestChannel"/>
    
    <jms:outbound-gateway request-channel="someServiceRequestChannel"
                         request-destination="some.queue"
                         reply-destination="some.other.queue"/>
    
    <channel id="someServiceReplyChannel"/>
    Note how JmsOutboundGateway configuration does not have an reply-channel anymore. A temporary channel will be created from which the message will be picked up by the main Gateway.

    Let me know how.

  5. #5
    Join Date
    Jun 2010
    Posts
    17

    Default

    Hi Oleg,

    Thanks for your reply. I did what you suggested and, unfortunately, got the same results. I originally did not have the gateway but only the jms:outbound-gateway and got the timeout every time I made a second request.

    The client code uses the service interface to call the remote service twice. If I remove all of the business logic on the server and simply have the server echo the message the exception still occurs on the second request/response cycle.

    If I code the client to send only one message and terminate no exception is thrown. If I run the client multiple times in succession sending only one message each time, leaving the server on the entire time, there are no problems. As soon as I have the client send two (or more) messages during one run, the exception occurs. I'm thinking that the client is not releasing some resource but don't have an idea of what that might be. It seems that the service side is working fine.
    Last edited by w2m; Jun 15th, 2010 at 04:43 PM.

  6. #6
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    Can you provide the revised configuration?

  7. #7
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Indeed, since your previous configuration was generating slightly different error

  8. #8
    Join Date
    Jun 2010
    Posts
    17

    Default

    The server configuration did not change at all. The client configuration changed per Oleg's suggestion. The error message has always been the same (see below):

    Client Configuration
    Code:
    	<gateway id="someService" service-interface="services.SomeService" 
    			   default-request-channel="someServiceRequestChannel" 
    			   default-reply-channel="someServiceReplyChannel"/>
    
    	<channel id="someServiceRequestChannel"/>
    
    	<jms:outbound-gateway request-channel="someServiceRequestChannel"
    			  request-destination="some.queue"
    			  reply-destination="some.other.queue"/>
    	
    	<channel id="someServiceReplyChannel"/>

    Stack Trace:
    Code:
    Exception in thread "main" org.springframework.integration.message.MessageTimeoutException: failed to receive JMS response within timeout of: 5000ms
    	at org.springframework.integration.jms.JmsOutboundGateway.handleRequestMessage(JmsOutboundGateway.java:305)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:91)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:63)
    	at org.springframework.integration.endpoint.HandlerInvocationChain.handleMessage(HandlerInvocationChain.java:58)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:103)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:90)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:43)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:176)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:149)
    	at org.springframework.integration.channel.MessageChannelTemplate.doSend(MessageChannelTemplate.java:224)
    	at org.springframework.integration.channel.MessageChannelTemplate.doSendAndReceive(MessageChannelTemplate.java:251)
    	at org.springframework.integration.channel.MessageChannelTemplate.sendAndReceive(MessageChannelTemplate.java:216)
    	at org.springframework.integration.gateway.AbstractMessagingGateway.sendAndReceiveMessage(AbstractMessagingGateway.java:174)
    	at org.springframework.integration.gateway.AbstractMessagingGateway.sendAndReceive(AbstractMessagingGateway.java:157)
    	at org.springframework.integration.gateway.AbstractMessagingGateway.sendAndReceive(AbstractMessagingGateway.java:148)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:213)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:182)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    Last edited by w2m; Jun 15th, 2010 at 06:08 PM.

  9. #9
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    What messaging system are you using? The error message simply states that JMSGateway was waiting for the reply to be sent and it was not delivered in 5 seconds so it timed out. Try to increase timeout via reply-timeout attribute.

    I can give you working configuration that I was using via ActiveMQ Embedded Broker

  10. #10
    Join Date
    Jun 2010
    Posts
    17

    Default

    I am using ActiveMQ.

    I increased the timeout to 15 seconds and set the server to only echo the request message (no business processing). The same timeout exception occurs.

    With the original client configuration, I could see the second reply message on the queue even though the client wasn't reading it and timing out.

    If a client only sends one message, I can use multiple clients and they all get their reply. However, if one client sends two messages, the exception occurs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •