On Wed, May 12, 2010 at 1:09 AM, Guillaume Nodet <gno...@gmail.com> wrote: > Sorry, the message has been sent before being finished. > > On Tue, May 11, 2010 at 17:58, Guillaume Nodet <gno...@gmail.com> wrote: > It's been a long time I ad not looked at the asynchronous support in > Camel.I had to do so today and I must say I'm a bit disapointed. > What's the way to have a scalable route using http such as even the > one in the documentation: > from("jetty:http://localhost:8080/service").to("jhc:http://localhost/service-impl"); > > Given the jetty consumer doesn't use continuations anymore, I don't > understand. > I know the asynchronous API has been refactored and (mea culpa), i > haven't paid much attention to it. >
> But I think there has been a big misunderstanding about the purpose of > this api.The goal was not to process things in another thread. The > goal was to be scalable. The AsyncProcessor was only a tool to > achieve that. Maybe not the best one, but still it was working. > In Camel 2.x you can add a callback on the Exchange using the following API: /** * Adds a {...@link org.apache.camel.spi.Synchronization} to be invoked as callback when * this exchange is completed. * * @param onCompletion the callback to invoke on completion of this exchange */ void addOnCompletion(Synchronization onCompletion); Then Camel will invoke this callback when the Exchange is completed (eg. done or failed) Camel will transfer the callback if the Exchange is being transferred from one thread to another. So you can route it over a SEDA queue and then have the callback invoked at the very last. The Synchronization have methods which is invoked according to the situation. There is a SynchronizationAdapter which you can use as base class. public interface Synchronization { /** * Called when the processing of the message exchange is complete * * @param exchange the exchange being processed */ void onComplete(Exchange exchange); /** * Called when the processing of the message exchange has failed for some reason. * The exception which caused the problem is in {...@link Exchange#getException()} and * there could be a fault message via {...@link org.apache.camel.Message#isFault()} * * @param exchange the exchange being processed */ void onFailure(Exchange exchange); } > > Now, the only implementation of AsyncProcessor is the > JettyHttpProducer [continued] > Looking at what needs to be done, you would have to do something like: > to("jetty:http://xxx?jetty.async=true")or something like that which does > not > I don't understand the purpose of the new api. Can somebody shed some light ? > > -- > Cheers, > Guillaume Nodet > ------------------------ > Blog: http://gnodet.blogspot.com/ > ------------------------ > Open Source SOA > http://fusesource.com > > > > > > -- > Cheers, > Guillaume Nodet > ------------------------ > Blog: http://gnodet.blogspot.com/ > ------------------------ > Open Source SOA > http://fusesource.com > > > > > -- > Cheers, > Guillaume Nodet > ------------------------ > Blog: http://gnodet.blogspot.com/ > ------------------------ > Open Source SOA > http://fusesource.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