HTTP to File cuts messages

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTP to File cuts messages

Leen Toelen
Hi,

I have the follwoing route defined:

                <route id="RestToTempDir">
                        <from uri="jetty:http://0.0.0.0:8162/muyrl" />
                        <setHeader headerName="CamelFileExchangeFile">
                                <header>message.id</header>
                        </setHeader>
                        <to
                                uri="file://c:/temp/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml" />
                        <setBody>
                                <header>CamelFileExchangeFile</header>
                        </setBody>
                </route>

Now when I send a file to this url (52K in general), the client gets a
200 OK back, but only a part of the files is written to disk (always
in chunks of 1,2,4 or 8KB).

If I replace it with a two phase route, the files are written completely.

                <route id="RestToTempDir">
                        <from uri="jetty:http://0.0.0.0:8162/myurl" />
                        <inOnly uri="activemq:topic=TempTopic" />
                        <setBody>
                                <header>message.id</header>
                        </setBody>
                        <setHeader headerName="CamelFileExchangeFile">
                                <header>message.id</header>
                        </setHeader>
                </route>
                <route id="TempAssemblyToTempArchiveDirectory">
                        <from uri="activemq:topic:TempTopic" />
                        <setHeader headerName="CamelFileExchangeFile">
                                <header>message.id</header>
                        </setHeader>
                        <to
                                uri="file://c:/xmlarchive_noxslt/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml"
/>
                </route>

Does anyone see what I am doing wrong, I would like the 1 phase route.
I am using camel 2.1.0.

Regards,
Leen Toelen
Reply | Threaded
Open this post in threaded view
|

Re: HTTP to File cuts messages

Claus Ibsen-2
Hi

Try using a <convertBodyTo type="java.lang.String"/> to force it to
convert the stream to string before writing.


On Tue, Feb 16, 2010 at 11:44 AM, Leen Toelen <[hidden email]> wrote:

> Hi,
>
> I have the follwoing route defined:
>
>                <route id="RestToTempDir">
>                        <from uri="jetty:http://0.0.0.0:8162/muyrl" />
>                        <setHeader headerName="CamelFileExchangeFile">
>                                <header>message.id</header>
>                        </setHeader>
>                        <to
>                                uri="file://c:/temp/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml" />
>                        <setBody>
>                                <header>CamelFileExchangeFile</header>
>                        </setBody>
>                </route>
>
> Now when I send a file to this url (52K in general), the client gets a
> 200 OK back, but only a part of the files is written to disk (always
> in chunks of 1,2,4 or 8KB).
>
> If I replace it with a two phase route, the files are written completely.
>
>                <route id="RestToTempDir">
>                        <from uri="jetty:http://0.0.0.0:8162/myurl" />
>                        <inOnly uri="activemq:topic=TempTopic" />
>                        <setBody>
>                                <header>message.id</header>
>                        </setBody>
>                        <setHeader headerName="CamelFileExchangeFile">
>                                <header>message.id</header>
>                        </setHeader>
>                </route>
>                <route id="TempAssemblyToTempArchiveDirectory">
>                        <from uri="activemq:topic:TempTopic" />
>                        <setHeader headerName="CamelFileExchangeFile">
>                                <header>message.id</header>
>                        </setHeader>
>                        <to
>                                uri="file://c:/xmlarchive_noxslt/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml"
> />
>                </route>
>
> Does anyone see what I am doing wrong, I would like the 1 phase route.
> I am using camel 2.1.0.
>
> Regards,
> Leen Toelen
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: HTTP to File cuts messages

Leen Toelen
Hi,

this works indeed, thanks a lot. Should I create  a bug report for
this or not, to me it seems non-obvious to add the convertBodyTo or
ending up with partial output.

Regards,
Leen

On Tue, Feb 16, 2010 at 2:45 PM, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> Try using a <convertBodyTo type="java.lang.String"/> to force it to
> convert the stream to string before writing.
>
>
> On Tue, Feb 16, 2010 at 11:44 AM, Leen Toelen <[hidden email]> wrote:
>> Hi,
>>
>> I have the follwoing route defined:
>>
>>                <route id="RestToTempDir">
>>                        <from uri="jetty:http://0.0.0.0:8162/muyrl" />
>>                        <setHeader headerName="CamelFileExchangeFile">
>>                                <header>message.id</header>
>>                        </setHeader>
>>                        <to
>>                                uri="file://c:/temp/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml" />
>>                        <setBody>
>>                                <header>CamelFileExchangeFile</header>
>>                        </setBody>
>>                </route>
>>
>> Now when I send a file to this url (52K in general), the client gets a
>> 200 OK back, but only a part of the files is written to disk (always
>> in chunks of 1,2,4 or 8KB).
>>
>> If I replace it with a two phase route, the files are written completely.
>>
>>                <route id="RestToTempDir">
>>                        <from uri="jetty:http://0.0.0.0:8162/myurl" />
>>                        <inOnly uri="activemq:topic=TempTopic" />
>>                        <setBody>
>>                                <header>message.id</header>
>>                        </setBody>
>>                        <setHeader headerName="CamelFileExchangeFile">
>>                                <header>message.id</header>
>>                        </setHeader>
>>                </route>
>>                <route id="TempAssemblyToTempArchiveDirectory">
>>                        <from uri="activemq:topic:TempTopic" />
>>                        <setHeader headerName="CamelFileExchangeFile">
>>                                <header>message.id</header>
>>                        </setHeader>
>>                        <to
>>                                uri="file://c:/xmlarchive_noxslt/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml"
>> />
>>                </route>
>>
>> Does anyone see what I am doing wrong, I would like the 1 phase route.
>> I am using camel 2.1.0.
>>
>> Regards,
>> Leen Toelen
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Reply | Threaded
Open this post in threaded view
|

Re: HTTP to File cuts messages

Claus Ibsen-2
On Tue, Feb 16, 2010 at 3:33 PM, Leen Toelen <[hidden email]> wrote:
> Hi,
>
> this works indeed, thanks a lot. Should I create  a bug report for
> this or not, to me it seems non-obvious to add the convertBodyTo or
> ending up with partial output.
>

Feel free to create a JIRA ticket.

However converting the body to a String is a safe way to ensure all
body is avail in memory. When working with streams oddities can happen
:)
But would be nice if jetty and file works nicely.

> Regards,
> Leen
>
> On Tue, Feb 16, 2010 at 2:45 PM, Claus Ibsen <[hidden email]> wrote:
>> Hi
>>
>> Try using a <convertBodyTo type="java.lang.String"/> to force it to
>> convert the stream to string before writing.
>>
>>
>> On Tue, Feb 16, 2010 at 11:44 AM, Leen Toelen <[hidden email]> wrote:
>>> Hi,
>>>
>>> I have the follwoing route defined:
>>>
>>>                <route id="RestToTempDir">
>>>                        <from uri="jetty:http://0.0.0.0:8162/muyrl" />
>>>                        <setHeader headerName="CamelFileExchangeFile">
>>>                                <header>message.id</header>
>>>                        </setHeader>
>>>                        <to
>>>                                uri="file://c:/temp/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml" />
>>>                        <setBody>
>>>                                <header>CamelFileExchangeFile</header>
>>>                        </setBody>
>>>                </route>
>>>
>>> Now when I send a file to this url (52K in general), the client gets a
>>> 200 OK back, but only a part of the files is written to disk (always
>>> in chunks of 1,2,4 or 8KB).
>>>
>>> If I replace it with a two phase route, the files are written completely.
>>>
>>>                <route id="RestToTempDir">
>>>                        <from uri="jetty:http://0.0.0.0:8162/myurl" />
>>>                        <inOnly uri="activemq:topic=TempTopic" />
>>>                        <setBody>
>>>                                <header>message.id</header>
>>>                        </setBody>
>>>                        <setHeader headerName="CamelFileExchangeFile">
>>>                                <header>message.id</header>
>>>                        </setHeader>
>>>                </route>
>>>                <route id="TempAssemblyToTempArchiveDirectory">
>>>                        <from uri="activemq:topic:TempTopic" />
>>>                        <setHeader headerName="CamelFileExchangeFile">
>>>                                <header>message.id</header>
>>>                        </setHeader>
>>>                        <to
>>>                                uri="file://c:/xmlarchive_noxslt/?fileName=${date:now:yyyyMMdd}/asm-${id}.xml"
>>> />
>>>                </route>
>>>
>>> Does anyone see what I am doing wrong, I would like the 1 phase route.
>>> I am using camel 2.1.0.
>>>
>>> Regards,
>>> Leen Toelen
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus