You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "ibcoleman@gmail.com" <ib...@gmail.com> on 2014/03/25 12:32:06 UTC
Making Periodic HTTP Request Using Timer
I'm trying to do something which seems like it should be very simple, but
instead is turning out to be very difficult.
I have a very straightforward REST URL that I want to poll periodically,
retrieve the JSON response, and then process that response. I managed to
successfully generate an http request based on the timer interval, but the
Message body is null when the Processor gets to it.
So I have an rsClient:
And following route:
I know I'm probably missing something simple, because almost all of the
documentation I've seen doesn't bother going into any detail, just saying,
"Client calls are trivial!"
Thanks for any help!
--Ian
--
View this message in context: http://camel.465427.n5.nabble.com/Making-Periodic-HTTP-Request-Using-Timer-tp5749336.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Making Periodic HTTP Request Using Timer
Posted by Ian Coleman <ib...@gmail.com>.
On Tue, Mar 25, 2014 at 10:00 AM, Donald Whytock <dw...@apache.org>wrote:
> On Tue, Mar 25, 2014 at 7:32 AM, ibcoleman@gmail.com <ibcoleman@gmail.com
> >wrote:
>
> > I'm trying to do something which seems like it should be very simple, but
> > instead is turning out to be very difficult.
> >[...]
>
> Were you including images in that email? Images and attachments often
> don't make it on the mailing list.
>
> Don
>
Hi Don,
Sorry, I think Nabble ate my code snippets because they were enclosed in
xml. Let me try that again:
The client is:
<bean id="camelRouting"
class="com.wireandwheel.demonstrations.ws.routes.ServerRoutes"/>
<cxf:rsClient id="wmataBusLineSvc"
address="http://api.wmata.com/Bus.svc/json/jRoutes?api_key=kfgpmgvfgacx98de9q3xazww"
serviceClass="com.wireandwheel.demonstrations.ws.service.RemoteService"
loggingFeatureEnabled="true" skipFaultLogging="true">
</cxf:rsClient>
<!-- The camel route context -->
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<contextScan/>
<camel:template id="camelTemplate"/>
<camel:routeBuilder ref="camelRouting"/>
</camel:camelContext>
And the route is:
from("timer:aTimer?fixedRate=true&period=10s")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.to("cxfrs://bean://wmataBusLineSvc")
.to("bean:itemRetriever")
.to("log:com.wireandwheel.demonstrations?level=INFO")
.process(aProcessor);
I was able to get it working by switching from cxf to http4:
from("timer:aTimer?fixedRate=true&period=10s")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.to("http4://
api.wmata.com/Bus.svc/json/jRoutes?api_key=kfgpmgvfgacx98de9q3xazww")
.unmarshal("json")
.to("bean:wmataRoutes")
.to("log:com.wireandwheel.demonstrations?level=INFO")
.process(aProcessor);
Re: Making Periodic HTTP Request Using Timer
Posted by Donald Whytock <dw...@apache.org>.
On Tue, Mar 25, 2014 at 7:32 AM, ibcoleman@gmail.com <ib...@gmail.com>wrote:
> I'm trying to do something which seems like it should be very simple, but
> instead is turning out to be very difficult.
>
> I have a very straightforward REST URL that I want to poll periodically,
> retrieve the JSON response, and then process that response. I managed to
> successfully generate an http request based on the timer interval, but the
> Message body is null when the Processor gets to it.
>
> So I have an rsClient:
>
>
>
>
> And following route:
>
>
>
> I know I'm probably missing something simple, because almost all of the
> documentation I've seen doesn't bother going into any detail, just saying,
> "Client calls are trivial!"
>
> Thanks for any help!
>
> --Ian
>
Were you including images in that email? Images and attachments often
don't make it on the mailing list.
Don