Announcement Announcement Module
Collapse
No announcement yet.
Get message info in handleMessage class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get message info in handleMessage class

    Hi,

    I've made a working version in SpringMQ to communicate between Java and Ruby. Everything is working quite well. So compliments for that.

    I'm using a MessageHandler class that has a

    public ReturnObject handleMessage(RecieveObject object)
    {
    ...
    }

    method.

    The problem over here is when the message that is received and transformed misses a replyTo header, I'm getting an exception when return the response to the queue. After that the same message is handled again and I'm getting in an infinitive loop.

    Is there some possibility to determine whether the received message contains a replyTo header, so I can act on this one?

    Thanks.
    AJ

  • #2
    You can get a reference to the whole Message in your handler, with all the headers and everything. Doing it that way would mean you'd have to do the conversion to ReceiveObject (sic) inside the handler. Or you could add the replyTo header to your ReceiveObject, and provide a MessageConverter that knows how to populate it (that would be my choice probably). Or you could extend the MessageListenerAdapter and extract the handler method arguments in any way you like.

    Comment


    • #3
      Hi Dave,

      Thanks for your response. I think I will extend the MessageListenerAdapter to get grip on the Message, maybe a good feature anyway.

      Thanks.
      AJ

      Comment


      • #4
        I created a custom listener class with the possibility to set the message via a MessageHolder interface.

        Maybe it is usefull to add this to the MessageListenerAdapter. Here is the code: Attachment
        Attached Files

        Comment


        • #5
          Your approach looks dangerous because it is not thread safe. I will try and make it easier to use an override of buildListenerArguments() (https://jira.springsource.org/browse/AMQP-180).

          Comment


          • #6
            ...or maybe you could override handleResult() and get the behaviour you need (which I didn't really understand properly)?

            Comment


            • #7
              Okay, thanks for your response, I wasn't aware that the message handler isn't a prototype bean. The only thing I need to know is, contains the message a reply to property.

              I can fix this on a different way. Thanks for you feedback!

              Comment

              Working...
              X