You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Leen Toelen <to...@gmail.com> on 2010/02/16 11:44:59 UTC

HTTP to File cuts messages

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

Re: HTTP to File cuts messages

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Feb 16, 2010 at 3:33 PM, Leen Toelen <to...@gmail.com> 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 <cl...@gmail.com> 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 <to...@gmail.com> 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

Re: HTTP to File cuts messages

Posted by Leen Toelen <to...@gmail.com>.
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 <cl...@gmail.com> 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 <to...@gmail.com> 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
>

Re: HTTP to File cuts messages

Posted by Claus Ibsen <cl...@gmail.com>.
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 <to...@gmail.com> 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