You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by jromine <jr...@gmail.com> on 2009/11/12 04:36:56 UTC
Copying a NormalizedMessage with attachments
The copy method of org.apache.servicemix.common.util.MessageUtil does not
seem to handle attachments correctly in some cases. When an attachment is
created using the org.apache.servicemix.components.util.BinaryFileMarshaler,
it will be implemented as FileInputStream and can only be read successfully
once. MessageUtil.copy() reads the source attachment and successfully
copies it but, in the process, makes the original attachment unusable.
To work around this problem, I created my own MessageUtil class and modified
it so that it creates two copies and assigns one back to the source
attachment (see attached file).
I http://old.nabble.com/file/p26312893/MyUtil.java MyUtil.java
If there is a better way to do this, I would be really interested in hearing
about it. Otherwise, I'd like to get a similar change made to the real
MessageUtil.
--
View this message in context: http://old.nabble.com/Copying-a-NormalizedMessage-with-attachments-tp26312893p26312893.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Copying a NormalizedMessage with attachments
Posted by Jeff Romine <jr...@gmail.com>.
Yes. I should be able to get to this soon.
-Jeff Romine
Gert Vanthienen wrote:
>
> L.S.,
>
> Yes, that fix seems to make sense. Could you raise a JIRA issue and
> attach this sample (or even better: a patch ;) )?
>
> Thanks,
>
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
>
>
>
> 2009/11/12 jromine <jr...@gmail.com>:
>>
>>
>> The copy method of org.apache.servicemix.common.util.MessageUtil does not
>> seem to handle attachments correctly in some cases. When an attachment
>> is
>> created using the
>> org.apache.servicemix.components.util.BinaryFileMarshaler,
>> it will be implemented as FileInputStream and can only be read
>> successfully
>> once. MessageUtil.copy() reads the source attachment and successfully
>> copies it but, in the process, makes the original attachment unusable.
>>
>> To work around this problem, I created my own MessageUtil class and
>> modified
>> it so that it creates two copies and assigns one back to the source
>> attachment (see attached file).
>>
>> I http://old.nabble.com/file/p26312893/MyUtil.java MyUtil.java
>>
>> If there is a better way to do this, I would be really interested in
>> hearing
>> about it. Otherwise, I'd like to get a similar change made to the real
>> MessageUtil.
>> --
>> View this message in context:
>> http://old.nabble.com/Copying-a-NormalizedMessage-with-attachments-tp26312893p26312893.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
>
--
View this message in context: http://old.nabble.com/Copying-a-NormalizedMessage-with-attachments-tp26312893p26487211.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Copying a NormalizedMessage with attachments
Posted by Gert Vanthienen <ge...@gmail.com>.
L.S.,
Yes, that fix seems to make sense. Could you raise a JIRA issue and
attach this sample (or even better: a patch ;) )?
Thanks,
Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/
2009/11/12 jromine <jr...@gmail.com>:
>
>
> The copy method of org.apache.servicemix.common.util.MessageUtil does not
> seem to handle attachments correctly in some cases. When an attachment is
> created using the org.apache.servicemix.components.util.BinaryFileMarshaler,
> it will be implemented as FileInputStream and can only be read successfully
> once. MessageUtil.copy() reads the source attachment and successfully
> copies it but, in the process, makes the original attachment unusable.
>
> To work around this problem, I created my own MessageUtil class and modified
> it so that it creates two copies and assigns one back to the source
> attachment (see attached file).
>
> I http://old.nabble.com/file/p26312893/MyUtil.java MyUtil.java
>
> If there is a better way to do this, I would be really interested in hearing
> about it. Otherwise, I'd like to get a similar change made to the real
> MessageUtil.
> --
> View this message in context: http://old.nabble.com/Copying-a-NormalizedMessage-with-attachments-tp26312893p26312893.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>