Results 1 to 2 of 2

Thread: Publish-subscribe channel messages are passed by reference?

  1. #1
    Join Date
    Oct 2012
    Posts
    10

    Default Publish-subscribe channel messages are passed by reference?

    Hi Integrators,

    I have a question about a publish-subscribe channel. It seems to me, that the very idea of this channel is to send a separate message to subscribed listeners, but what I see in my test project is that if one of the listeners attempts to change the incoming message, this change is propagated to all other listeners, so the message is passed by reference, not a separate copy created for every listener. Is it by design? Or am I missing something?

    Thanks in advance for your response!
    Last edited by maxvor; Oct 16th, 2012 at 04:19 AM.

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    No; while the message itself is immutable, but the payload can be changed by other subscribers unless it, too, is immutable.

    The message simply holds a reference to the payload.

    If you want to leave the original payload unchanged, you need to clone it, perhaps in a transformer.

    Hope that helps.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

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