Announcement Announcement Module
No announcement yet.
jms-source cannot be configured with a jms-template Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    DefaultIncomingMessageHandler is our custom class. sorry for the confusion. This class implements org.springframework.integration.handler.MessageHan dler.

    I am not sure, if i get handle to jms message inside handler so that i can acknowledge the message from handler. Is that possible or is there a way to achieve this using SI Message class.

    Thanks for your help.


    • #32

      Thanks for the explanation. I think I have a decent understanding of what you are doing. Let me see if I can explain what is happening as well as a potential solution.

      The JMS source adapter is receiving the JMS Message, converting it into a Spring Integration Message, and then sending that to a MessageChannel. The handler that you have registered within an endpoint is subscribed to that channel. However, due to the inherently asynchronous model, the thread that handles the JMS Message sees "success" as long as the Message was sent to the channel. The underlying message listener container then acknowledges the JMS Message (if you have client ack mode). Meanwhile your handler is actually receiving the converted Spring Integration Message from the channel in another thread. Hopefully that makes sense (but please let me know if it does not).

      What you should do is use a SynchronousChannel (newly added in M3) instead of the default asynchronous SimpleChannel. We will soon be adding namespace support, but for now this will require an explicit bean definition. The difference with a SynchronousChannel is that your handler will be executed on the same thread that sends to the channel. If your handler throws an Exception, the underlying Spring MessageListener container will not acknowledge the Message.

      Hope that helps.


      • #33
        Once again thanks for sharing interesting information.
        This should solve my problem. I have downloaded the M3 and will give try tomorrow
        Thanks once again.


        • #34
          Its not working as you explained. I tried to throw exception from my listener class and but message gets acknowledged and is removed from queue.

          We have defined our own errorhandler which implement ErrorHandler. can this cause any issues?

          The spring config xml snippet is as followed:
          <beans:bean id="mySyncChannel" class="org.springframework.integration.dispatcher. SynchronousChannel"/>

          <endpoint input-channel="mySyncChannel"

          any clue what is going here? any pointers to debug would be helpful.

          Thanks in advance /Vikas


          • #35
            If your error handler is not re-throwing an Exception, then the JMS listener container will believe that the listener executed successfully. Are you re-throwing an Exception?



            • #36
              Well, if I rethrown the error it goes in an endless loop. I wanted to post about this too, I will be doing that soon.

              However i tried removing our error handler but still same results. Message are consumed and are not available on queue.

              Here is error trace.. which show "AsyncMessageListenerInvoker." class. Is that as expected?

              11:23:54,076 WARN [MessagePublishingErrorHandler] failure occurred in messaging task
              at com.test.ResponseHandler.onMessage(ResponseHandler .java:55)
              at com.test.DefaultIncomingMessageHandler.update(Defa
              at java.util.Observable.notifyObservers(Observable.ja va:142)
              at org.springframework.integration.endpoint.DefaultMe ssageEndpoint.handle( 68)
              at org.springframework.integration.dispatcher.Default MessageDistributor.distribute(DefaultMessageDistri
              at org.springframework.integration.dispatcher.Synchro nousChannel.doSend(
              at ssageChannel.send(
              at ssageChannel.send(
              at org.springframework.integration.adapter.jms.Channe lPublishingJmsListener.onMessage(ChannelPublishing
              at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doInvokeListener(AbstractMessageLi
              at org.springframework.jms.listener.AbstractMessageLi stenerContainer.invokeListener(AbstractMessageList
              at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doExecuteListener(AbstractMessageL
              at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.doReceiveAndExecute(Abstrac
              at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.receiveAndExecute(AbstractP
              at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.invokeL istener(
              at org.springframework.jms.listener.DefaultMessageLis tenerContainer$



              • #37
                Your endless loop is due to the redelivery of the JMS Message, correct?


                • #38
                  When i rethrow an exception from my error handler, it goes back to error channel and error handler is called back again..and it goes in endless loop.

                  However, I removed the error handler still its not working. Message are getting drained from queue.
                  Any idea what i am missing here.?



                  • #39
                    hello vikas

                    did u get it working ?