Page 4 of 4 FirstFirst ... 234
Results 31 to 39 of 39

Thread: jms-source cannot be configured with a jms-template

  1. #31
    Join Date
    Jan 2008
    Posts
    16

    Default

    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

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

    Default

    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

  3. #33
    Join Date
    Jan 2008
    Posts
    16

    Default

    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

  4. #34
    Join Date
    Jan 2008
    Posts
    16

    Default

    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

  5. #35
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    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

  6. #36
    Join Date
    Jan 2008
    Posts
    16

    Default

    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

  7. #37
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

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

  8. #38
    Join Date
    Jan 2008
    Posts
    16

    Default

    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

  9. #39
    Join Date
    Sep 2007
    Posts
    21

    Default

    hello vikas

    did u get it working ?

Posting Permissions

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