camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: ProducerTemplate + timeout
Date Thu, 10 Dec 2009 16:07:07 GMT
On Thu, Dec 10, 2009 at 4:55 PM, Charles Moulliard <cmoulliard@gmail.com> wrote:
> If inside a camel bean we use a Producer to get the answer from a distant
> service which is available from a queue, can we define the timeout that our
> service must wait before to return an answer ?
>

If you use a producer then you are in the mercy whether that component
offers some timeout.
eg. http based often offer timeout configs.

However with Camel you can use the asyncRequestBody and then use the
Future API from JDK where you have timeout support.

See more here
http://camel.apache.org/async


> ex :
>
>    @EndpointInject(uri="jms:queue:inout")
>    ProducerTemplate producer;
>
>   public Incidents getIncidents() {
>
>        Incidents l = new Incidents();
>
>        // Call the distant service (= DAO Service) to get result
>        List<Incident> i = (List<Incident>) producer.requestBody(null);
//
> How CAN I define a timeout here (if possible) ?
>        l.setIncidents(i);
>
>        return l;
>    }
>
>
>        <camel:route>
>            <camel:from uri="jetty:
> http://localhost:8181?matchOnUriPrefix=true" />
>            <camel:to uri="cxfbean:reportIncidentServiceBean"/>
>        </camel:route>
>
>        <camel:route>
>            <camel:from uri="jms:queue:inout" />
>            <camel:bean ref="reportIncidentDAOService" method="getReports"/>
>        </camel:route>
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>
> Apache Camel Group :
> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>



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

Mime
View raw message