Announcement Announcement Module
Collapse
No announcement yet.
jms-source cannot be configured with a jms-template Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.
    Regards/Vikas

    Comment


    • #32
      Vikas,

      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.
      -Mark

      Comment


      • #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.
        Regards/Vikas

        Comment


        • #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"
          default-output-channel="RequestChannelPost"
          handler-ref="messageListener"

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

          Thanks in advance /Vikas

          Comment


          • #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?

            -Mark

            Comment


            • #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
              java.lang.NullPointerException
              at com.test.ResponseHandler.onMessage(ResponseHandler .java:55)
              at com.test.DefaultIncomingMessageHandler.update(Defa ultIncomingMessageHandler.java:13)
              at java.util.Observable.notifyObservers(Observable.ja va:142)
              at com.com.test.IncomingMessageListener.onNotify(Inco mingMessageListener.java:110)
              at com.com.test.IncomingMessageListener.handle(Incomi ngMessageListener.java:97)
              at org.springframework.integration.endpoint.DefaultMe ssageEndpoint.handle(DefaultMessageEndpoint.java:2 68)
              at org.springframework.integration.dispatcher.Default MessageDistributor.distribute(DefaultMessageDistri butor.java:93)
              at org.springframework.integration.dispatcher.Synchro nousChannel.doSend(SynchronousChannel.java:105)
              at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:134)
              at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:113)
              at org.springframework.integration.adapter.jms.Channe lPublishingJmsListener.onMessage(ChannelPublishing JmsListener.java:62)
              at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doInvokeListener(AbstractMessageLi stenerContainer.java:531)
              at org.springframework.jms.listener.AbstractMessageLi stenerContainer.invokeListener(AbstractMessageList enerContainer.java:466)
              at org.springframework.jms.listener.AbstractMessageLi stenerContainer.doExecuteListener(AbstractMessageL istenerContainer.java:435)
              at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.doReceiveAndExecute(Abstrac tPollingMessageListenerContainer.java:316)
              at org.springframework.jms.listener.AbstractPollingMe ssageListenerContainer.receiveAndExecute(AbstractP ollingMessageListenerContainer.java:255)
              at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.invokeL istener(DefaultMessageListenerContainer.java:887)
              at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.run(Def aultMessageListenerContainer.java:815)
              at java.lang.Thread.run(Thread.java:595)

              regards/vikas

              Comment


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

                Comment


                • #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.?

                  Regards/Vikas

                  Comment


                  • #39
                    hello vikas

                    did u get it working ?

                    Comment

                    Working...
                    X