Announcement Announcement Module
Collapse
No announcement yet.
How to remove some mesage headers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to remove some mesage headers

    Hi,

    At some point in my flow, I would like to remove some headers of my message because they would be interpreted by another part of the flow later.

    I tried using a Service Activator with a POJO and a method defined as the following:

    Code:
    public Message<?> cleanHeaders(Message<?> message) {
        return MessageBuilder.withPayload(message.getPayload()).build();
    }
    But this won't remove any header (it seems like they are added again by the AbstractReplyProducingMessageHandler)


    I also tried to include a header-enricher and set to null all the headers (although I would need to know the exhaustivity of my custom headers), but the following syntax is not accepted :

    Code:
    <int:header-enricher ...>
         <int:header name="foo"><null/></int:header>
    </int:header-enricher>
    Is there any way to do what I want?

    Thank you!

    Pierre

  • #2
    Pierre, for that you should use the <header-filter>:
    http://static.springsource.org/sprin...#header-filter

    HTH,
    Mark

    Comment


    • #3
      Thank you Mark, that's perfect!

      Do you consider it normal though that the Message is modified (only the headers in this case) when the return type of a Service Activator is of class "Message" ?
      The interesting part in allowing to return an object of class Message is to be able to add or remove headers, isn't it? If someone would like to keep all the headers unchanged, he still can copy them thanks to the MessageBuilder.

      Is there a reason about that behaviour?

      Thank you --

      Comment

      Working...
      X