Announcement Announcement Module
Collapse
No announcement yet.
JMS Gateway Timeout Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS Gateway Timeout

    Hello,

    I am using the JMS Outbound Gateway to send messages from a client to the server. To keep it simple I set up one Queue for the requests. The gateway is set up so that the answer will be sent through a special Queue for each client.

    Example:
    Client A:
    Code:
    <int-jms:outbound-gateway id="jmsout"
      request-channel="toJmsChannel"
      reply-channel="jmsReplyChannelUnfiltered"
      request-destination="requestQueue"
      reply-destination="clientAQueue"/>
    Client B:
    Code:
    <int-jms:outbound-gateway id="jmsout"
      request-channel="toJmsChannel"
      reply-channel="jmsReplyChannelUnfiltered"
      request-destination="requestQueue"
      reply-destination="clientBQueue"/>
    The server receives the requests through a JMS Inbound Gateway.
    Code:
    <int-jms:inbound-gateway id="jmsin"
     request-destination="requestQueue"
     request-channel="fromJmsChannel" />
    When I run this configuration everything works fine except Spring does not close the connection to the client Queue on the client side after receiving and processing the message.

    Is there a chance to close these connections? I am afraid of killing my ActiveMQ server with too many consumers on the client queues.

  • #2
    In the JMS OutboundGateway, there is a finally block with this:
    Code:
    JmsUtils.closeMessageConsumer(messageConsumer);
    Is there any chance you could run with a debugger and a breakpoint there?

    Thanks,
    -Mark

    Comment


    • #3
      I did try it but the debugger does not reach the breakpoint.

      Comment


      • #4
        sorry, I tried to increase the receive-timeout and so everything went wrong .. now I am reaching the breakpoint ... what values do you need?

        Comment


        • #5
          Actually, can you describe the behavior that you are seeing?... I believe it's simply caching Consumers since that is the default behavior of DefaultMessageListenerContainer. You should not see the number grow beyond the number of concurrent consumers at any given time (and that can be controlled via configuration).

          Comment


          • #6
            Thanks for your reply.

            The Client is behaving like this: every time I place a request to the server the response increases the number of consumers of the client queue.
            So far I did the whole procedure until I reached a number of 30 consumers on one queue.

            I did not find the right point to set a border for that. Where can I find it?

            Comment


            • #7
              thank you for your advise. I checked my connectionFactory settings and found out how to stop caching. Now everything works fine. The only question is if I can set the number of cached consumers. In this case I would be able to enable caching but with a fixed number of cached instances.

              Comment


              • #8
                Can you try setting the 'concurrent-consumers' value on the gateway element?

                Comment


                • #9
                  I can only set the concurrent-consumers on the inbound gateway of the server so I think that this will not fix my problem. But the other option is fine for me.

                  Comment


                  • #10
                    Sorry. You're right... I was thinking about the wrong side

                    So, are you saying that everything is okay now that you've configured your ConnectionFactory?

                    Comment


                    • #11
                      yes. Thank you again. Have a good weekend.

                      Comment


                      • #12
                        I had the same problem with consumer connections increasing and have solved that problem by changing the connectionFactory settings as previously suggested. I still experience a timeout, though.

                        My configuration is similar to the Client A and server described by 13yo, however, my scenario is different. I have Client A send a request with a message channel, wait for a reply, and when it arrives, send a second request on the same message channel. The first reply arrives with no problem. However, the second fails with a MessageTimeoutException. The second reply is on the message queue waiting to be read 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. I have been sending the reply to stdout via an adapter.

                        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. Is my usage incorrect or is there some setting that is necessary for this scenario to work?

                        Comment

                        Working...
                        X