Announcement Announcement Module
No announcement yet.
message context is lost in error channel Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • message context is lost in error channel

    Hi In one of my projects i am using amqp gateway for doing a request/response kind of activity.

    My amqp gateway has a message conveter and is connected to a router, and service activtor down stream.

    I have also configured an error channel from my gateway, which generates an error code and sends a message with erro code back to the amqp message producer (client)

    When ever I have an exception from one of my down stream component, say service activator, I am having a ErrorMessage (with the exception as the payload) in my errorChannel( as expected ), but I am seeing that the ErrorMessage has no header information from the original request or the generated reply(error message) .
    This way components in my error channel looses the context of the actual message.

    Also, my client(message producer), does a correlation with the correlation Id, now when there is an error in my service activator, a error message(with error code) is sent back to the AMQP queue , but the reply message do not have any correlation id (lost while generating the error message), and hence my client drops of this error message.
    As a result the client times out instead of throwing the valid error code from service.

    Should the header information not be copied while creating the Error message as well?
    Is there any specific reason why we are not copying the original headers from the request when there is an error?

    I am using spring integration 2.2.0.M1,

    To me issues seems to be in line 246 of org.springframework.integration.gateway.MessagingG atewaySupport

    should it not be

    Message<?> errorMessage = new ErrorMessage(error, ((Message)object).getHeaders());
    instead of Message<?> errorMessage = new ErrorMessage(error); ?
    Last edited by kkcmadhu; Jun 18th, 2012, 04:38 AM.

  • #2
    The original message (including its headers) is available in the failedMessage property on the payload of the ErrorMessage. The payload is a MessagingException with failedMessage and cause properties.

    Simply add a transformer to your error flow (payload.failedMessage) before generating your error reply, and the headers will be available in the reply.
    Last edited by Gary Russell; Jun 18th, 2012, 06:43 PM.