Results 1 to 3 of 3

Thread: How to remove some mesage headers

Hybrid View

  1. #1
    Join Date
    Jun 2010
    Location
    Paris
    Posts
    106

    Default 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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

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

    HTH,
    Mark

  3. #3
    Join Date
    Jun 2010
    Location
    Paris
    Posts
    106

    Default

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

Tags for this Thread

Posting Permissions

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