You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Kameltreiber <st...@htw-aalen.de> on 2010/03/23 08:16:46 UTC

route from http to file, with Java DSL, howto?

Hi,
i just try to write a xml result from a http request to a file.
I'd like to use Java DSL
at the moment it looks like this

 from("http://example.com/")
        .setHeader(Exchange.FILE_NAME, constant("report.xml"))
        .to("file:target/reports");

I alreday checked the result, and there is one, but the report.xml never
gets created.
What am i doing wrong?

Regards...

-- 
View this message in context: http://old.nabble.com/route-from-http-to-file%2C-with-Java-DSL%2C-howto--tp27997011p27997011.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: route from http to file, with Java DSL, howto?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can use Content Enricher
http://camel.apache.org/content-enricher.html


from(timer:foo?period=5000").pollEnrich("http://someserver.com").setHeader(xxx).to(file:xxx");
Instead of timer you can also use quartz to use eg CRON like triggering.

In the future we will build in timer/quartz into the DSL as a first
class citizen so you can make nice readable DSL for that.


On Tue, Mar 23, 2010 at 8:45 AM, Kameltreiber
<st...@htw-aalen.de> wrote:
>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Tue, Mar 23, 2010 at 8:16 AM, Kameltreiber
>> <st...@htw-aalen.de> wrote:
>>>
>>> Hi,
>>> i just try to write a xml result from a http request to a file.
>>> I'd like to use Java DSL
>>> at the moment it looks like this
>>>
>>>  from("http://example.com/")
>>>        .setHeader(Exchange.FILE_NAME, constant("report.xml"))
>>>        .to("file:target/reports");
>>>
>>> I alreday checked the result, and there is one, but the report.xml never
>>> gets created.
>>> What am i doing wrong?
>>>
>>
>> What do you want? is example.com a HTTP service you want to expose
>> yourself?
>> Or do you want to poll data from an external HTTP service every X time?
>>
>> If its the former then you gotta use Jetty in the from to let it be
>> used as the HTTP server.
>> http://camel.apache.org/jetty
>>
>>   from("jetty:http://localhost:9080/")
>>
>> If the latter you have to use a scheduler such as Timer or Quartz to
>> trigger the poll.
>>
>> Ah thx,
>> the second one is my case...
>> i already tried to solve this with a PollingConsumer...
>> can i combine a PollingConsumer with Java DSL?
>>
>>
>>
>>> Regards...
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/route-from-http-to-file%2C-with-Java-DSL%2C-howto--tp27997011p27997011.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> 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
>>
>>
>
> --
> View this message in context: http://old.nabble.com/route-from-http-to-file%2C-with-Java-DSL%2C-howto--tp27997011p27997214.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
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: route from http to file, with Java DSL, howto?

Posted by Kameltreiber <st...@htw-aalen.de>.


Claus Ibsen-2 wrote:
> 
> On Tue, Mar 23, 2010 at 8:16 AM, Kameltreiber
> <st...@htw-aalen.de> wrote:
>>
>> Hi,
>> i just try to write a xml result from a http request to a file.
>> I'd like to use Java DSL
>> at the moment it looks like this
>>
>>  from("http://example.com/")
>>        .setHeader(Exchange.FILE_NAME, constant("report.xml"))
>>        .to("file:target/reports");
>>
>> I alreday checked the result, and there is one, but the report.xml never
>> gets created.
>> What am i doing wrong?
>>
> 
> What do you want? is example.com a HTTP service you want to expose
> yourself?
> Or do you want to poll data from an external HTTP service every X time?
> 
> If its the former then you gotta use Jetty in the from to let it be
> used as the HTTP server.
> http://camel.apache.org/jetty
> 
>   from("jetty:http://localhost:9080/")
> 
> If the latter you have to use a scheduler such as Timer or Quartz to
> trigger the poll.
> 
> Ah thx,
> the second one is my case...
> i already tried to solve this with a PollingConsumer...
> can i combine a PollingConsumer with Java DSL?
> 
> 
> 
>> Regards...
>>
>> --
>> View this message in context:
>> http://old.nabble.com/route-from-http-to-file%2C-with-Java-DSL%2C-howto--tp27997011p27997011.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 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
> 
> 

-- 
View this message in context: http://old.nabble.com/route-from-http-to-file%2C-with-Java-DSL%2C-howto--tp27997011p27997214.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: route from http to file, with Java DSL, howto?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 23, 2010 at 8:16 AM, Kameltreiber
<st...@htw-aalen.de> wrote:
>
> Hi,
> i just try to write a xml result from a http request to a file.
> I'd like to use Java DSL
> at the moment it looks like this
>
>  from("http://example.com/")
>        .setHeader(Exchange.FILE_NAME, constant("report.xml"))
>        .to("file:target/reports");
>
> I alreday checked the result, and there is one, but the report.xml never
> gets created.
> What am i doing wrong?
>

What do you want? is example.com a HTTP service you want to expose yourself?
Or do you want to poll data from an external HTTP service every X time?

If its the former then you gotta use Jetty in the from to let it be
used as the HTTP server.
http://camel.apache.org/jetty

  from("jetty:http://localhost:9080/")

If the latter you have to use a scheduler such as Timer or Quartz to
trigger the poll.


> Regards...
>
> --
> View this message in context: http://old.nabble.com/route-from-http-to-file%2C-with-Java-DSL%2C-howto--tp27997011p27997011.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
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