On Thu, Dec 10, 2009 at 5:30 PM, Charles Moulliard <cmoulli...@gmail.com> wrote:
> Awesome this new feature of Producer.
>
> I presume that I must use future.get(timeout) //
> http://java.sun.com/javase/6/docs/api/java/util/concurrent/Future.html#get%28long,%20java.util.concurrent.TimeUnit%29
>
> to check if an answer has been received within the period defined.
>

Yes exactly.

Beware I think it throws an exception for timeout so you may need try
.. catch around it. And if the task failed the get() will throw an
ExecutionException with the cause wrapped. You can read all about it
in the javadocs for this Future API stuff.



Its only the consumer who have a timeout directly in Camel.
As its the Polling Consumer EIP
http://camel.apache.org/polling-consumer.html

>
> 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
>
>
> On Thu, Dec 10, 2009 at 5:07 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:
>
>> On Thu, Dec 10, 2009 at 4:55 PM, Charles Moulliard <cmoulli...@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
>>
>



-- 
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 via email to