3 Replies Latest reply on Dec 11, 2007 12:11 PM by marklittle

    Is there any way to clone a Message?

    mwax

      I need to copy a message (I do not know if the underlying implementation is serializable or XML). Is there a way to do this?

        • 1. Re: Is there any way to clone a Message?
          marklittle

          There is no copy capability directly. What part of the Message do you want to copy? Header? Body?

          • 2. Re: Is there any way to clone a Message?
            mwax

            What I am trying to do is this:
            I have a splitter class which breaks up an incoming message into a series of smaller messages, each of which is routed to another service. In practice, the splitter iterates over the split parts of the initial message, replaces the unsplit contents at Body.DEFAULT_LOCATION with each split part, and then routes the modified message.

            What I want to do is hold on to the original message so that, in case of some error along the way, I can send this message to an error service. Any suggestions on how to do this?

            • 3. Re: Is there any way to clone a Message?
              marklittle

              You could externalize it and then internalize it. Take a look at Util.serialize and Util.deserialize. I think they're your best bet at the moment.