1 Reply Latest reply on Nov 11, 2009 9:40 PM by jromine

    how do i copy a NormalizedMessage with attachments without breaking it?

    jromine

      I have been trying to write a servicemix-bean component (not sure that is the right term) which:

       

      1. receives a message with an attachment sent by a file-poller component using the BinaryFileMarshaler.

      2. reads the attachment and does something based on it.

      3. copies the incoming message unaltered to the outgoing message.

       

      The problem is that reading the attachment ends up closing the input stream so that it can no longer be accessed.  I've tried making a copy of the NormalizedMessage using  MessageUtil.copy() but this has the same problem.

       

      Is there a straightforward way of doing this or do I need to write my own copy method for attachments?

       

      Thank's.

        • 1. Re: how do i copy a NormalizedMessage with attachments without breaking it?
          jromine

          If anybody is interested, I  was able to fix this by copying org.apache.servicemix.common.util.MessageUtil$MessageExchangeImpl and modifying it to create two copies of each attachment and write one of them back to the source message. 

           

          The attached file shows the new version.  It would be helpful if someone (a committer) could incorporate this or explain to me that there is a better solution.