Announcement Announcement Module
Collapse
No announcement yet.
Clear message body and headers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      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 ?

      Comment


      • #4
        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>

        Comment


        • #5
          Ok I'll do that, thx !

          Comment

          Working...
          X