Results 1 to 5 of 5

Thread: Clear message body and headers

  1. #1
    Join Date
    Dec 2012
    Posts
    8

    Default Clear message body and headers

    Hi,

    Is there a way to clear the message payload and headers at some point in a process flow? For example A receives a message, pipe it to B that will process it and pipe it to C: I'd like B to remove any Message payload and headers to start fresh.

    How should I do this ?

    Fabrice

  2. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    741

    Default

    Hello!

    Not sure what you want to get...
    Message is immutable Object, so each endpoint creates new Message before sending to the output-channel. Of course this Message contain payload as a result of work of that endpoint and it may copy headers from inbound Message.
    So, what do you want to send to the C?
    Explain, please your use-case.
    It sounds like you want to break message-flow and start a new one.
    By the way you can write some simple code:
    Code:
    <transformer id="transformer"
    			input-channel="input"
    			output-channel="output"
                            ref="someBean"
                            method="someMethod"/>
    
    public Message<?> someMethod(Message<?> message) {
           return MessageBuilder.withPayload("").build();
    }
    By the way: NULL payload isn't allowed by Spring Integration.

    Take care,
    Artem

  3. #3
    Join Date
    Dec 2012
    Posts
    8

    Default

    Quote Originally Posted by Cleric View Post
    Hello!

    Not sure what you want to get...
    Message is immutable Object, so each endpoint creates new Message before sending to the output-channel. Of course this Message contain payload as a result of work of that endpoint and it may copy headers from inbound Message.
    So, what do you want to send to the C?
    Explain, please your use-case.
    It sounds like you want to break message-flow and start a new one.
    By the way you can write some simple code:
    Code:
    <transformer id="transformer"
    			input-channel="input"
    			output-channel="output"
                            ref="someBean"
                            method="someMethod"/>
    
    public Message<?> someMethod(Message<?> message) {
           return MessageBuilder.withPayload("").build();
    }
    By the way: NULL payload isn't allowed by Spring Integration.

    Take care,
    Artem
    Hi Artem,
    You are right. My problem is that A enriches the message and I want to break the message flow and start a new one. That's right but has to still be the same 'thread' meaning by that not a java thread of course but the same process flow.

    Is it a bit more clear ?

  4. #4
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    741

    Default

    And which problem do you have?
    You don't need some headers? The <header-filter/> is for you.
    You aren't interested in payload? So, just ignore it in C.
    Or just use a trick which I show above: in this case your payload will just an empty String and header will be clear, because Transformer endpoint doesn't copy headers from request.
    In any case you have to have some not null payload. E.g.
    HTML Code:
    <inbound-channel-adapter expression="" channel="input">
    	<poller fixed-delay="1000"/>
    </inbound-channel-adapter>

  5. #5
    Join Date
    Dec 2012
    Posts
    8

    Default

    Ok I'll do that, thx !

Posting Permissions

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