On Tue, Jul 7, 2009 at 4:35 AM, Ole Jørgensen<o...@amfibia.dk> wrote: > > Im new to Camel and wonder if I can use it for what Im doing. Welcome on the ride.
> > I have a existing spring webapplication with a servlet context. > > jdk1.6.0_11 > tomcat-6.0.18 > spring-framework-2.5.6 > > Part of its job is to take user input and update data on 5 different > websites. Now the process is serial, first one then the next..... - it takes > too long time. > My idea is to use Camel to be able to do these updates in parallel. > I was reading the async page and I think the Asynchronous Request Reply > example sounds right. http://camel.apache.org/async Yeah it sounds right, all though Camel also have the multicast DSL that can work in parallel. Its something along the lines like this (no code editor in gmail, yet) from(x).multicast().parallelProcessing().to(a, b, c, d, e); The async DSL gives you a more low level control what is going on as you got a handle to the task. And the handle is the JDK Future handle so you can cancel the task, check whether its done etc. As opposed to the multicast DSL above that works on a higher level abstraction. multicast() means that each of the endpoints in the to receives the *same* message. parallelProcessing() makes it use a new task for routing the message, eg as you want in parallel. The multicast also works with an AggregationStrategy if you need to collect the responses from the 5 endpoints. from(x).multicast(new MyAggregationStrategy()).parallelProcessing().to(a, b, c, d, e); Then in the aggregation strategy you got 2 inputs - oldExchange - newExchange The oldExchange is the "aggregated" response so far The newExchange is a new response from one of the 5 tasks This is useable if you need to do additional routing afterwords, eg routing the message to another BEAN to do more work or send the combined response to a JMS queue etc. > > Can I define the Camel context in applicationContext.xml and run it next to > the servlet context ? Yes its just adding it to the spring xml file. See this tutorial http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html > How can I send messages to a queue in the Camel context from a servlet ? > Or do I have to make a seperate application and send messages between them > via JMS ? You can use the ProducerTemplate in Camel to send a message, eg to get started. Just declare it in the camelcontext xml tag and grab it using the spring style as it just a bean with an id. And then fire a message to Camel. See this tutorial how to do it http://camel.apache.org/tutorial-axis-camel.html > Is there a working example somewhere of what I want to do ? > Any suggestions are wellcome. > > Thanks > > -- > View this message in context: > http://www.nabble.com/Camel-in-existing-webapp-tp24366220p24366220.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus