Hi Camel has a service interface: org.apache.camel.Service with callbacks for start and stop = lifecycle. But I doubt that your processor will receive these callback.
1) If you don't use an anonymous inner class as processor you can just create your processor instance once, and then init the XML. In the camel route you can pass a reference to your object with .processRef() For example in your route builder (if using java): Processor myProcessor = new MyProcessor(); myProcessor.myInit(); // init or do it in the constructor from("xxx").processRef(myProcessor).to("seda:yyy")... 2) If you are using Spring xml for lifecycle management then you can use spring to handle this and in the Camel route you can use .bean("mySpringBeanId") to invoke you bean where you can do you code as the processor did. When you use bean then you is able to be less dependent on Camel interfaces and in fact you can write it as a POJO with no imports for Camel. Camel will invoke your method. from("xxx").bean("mySpringBeanId").to("seda:yyy")... See wiki doc http://activemq.apache.org/camel/bean.html Med venlig hilsen Claus Ibsen ...................................... Silverbullet Skovsgårdsvænget 21 8362 Hørning Tlf. +45 2962 7576 Web: www.silverbullet.dk -----Original Message----- From: raulvk [mailto:[EMAIL PROTECTED] Sent: 11. september 2008 12:54 To: camel-user@activemq.apache.org Subject: RE: Synchronous/asynchronous bridge Ok, got it half-working. Thanks! What I have actually done is I have created a private class inside that implements Processor, and I am using the .process() DSL instruction to run it through it. However, the problem I am facing now is that because the response is actually returned to a CXF endpoint via ServiceMix, this endpoint expects the message within an <jbi:message> ... </jbi:message> envelope. Therefore, the XML that I ought to send back is getting a bit more complex. I am thinking of loading the response XML from a file from the classpath. I could do this within the process() method, but this would keep loading and discarding the XML over and over again, right? Do processors have lifecycle methods, such that I can load the XML into memory once within an init() method? What solution do you suggest to only load the XML from the file into memory ONCE? Thank you!! Claus Ibsen wrote: > > Hi > > BTW: .transform is a new DSL in Camel 1.4. And since you are using > ServiceMix it might not be with the latest Camel release. > > You can then use .setOutBody instead > > > Med venlig hilsen > > Claus Ibsen > ...................................... > Silverbullet > Skovsgårdsvænget 21 > 8362 Hørning > Tlf. +45 2962 7576 > Web: www.silverbullet.dk > > -----Original Message----- > From: Claus Ibsen [mailto:[EMAIL PROTECTED] > Sent: 11. september 2008 08:49 > To: camel-user@activemq.apache.org > Subject: RE: Synchronous/asynchronous bridge > > Hi > > Yes this is possible. The solution is to use a queue where you "split" the > request. You can use a JMS queue or a the SEDA queues that Camel has > out-of-the-box. > http://activemq.apache.org/camel/seda.html > > The transform DSL is used for setting the OUT body = the response to the > original caller. > > > Here is an example of such a scenariou. I have build a unit test to > demonstrate this: > > public void testSendAsync() throws Exception { > MockEndpoint mock = getMockEndpoint("mock:result"); > mock.expectedBodiesReceived("Hello World"); > > Object out = template.requestBody("direct:start", "Hello World"); > assertEquals("OK", out); > > assertMockEndpointsSatisfied(); > } > > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > public void configure() throws Exception { > from("direct:start") > // send it to the seda queue that is async > .to("seda:next") > // return a constant response > .transform(constant("OK")); > > from("seda:next").to("mock:result"); > } > }; > } > > > > > Med venlig hilsen > > Claus Ibsen > ...................................... > Silverbullet > Skovsgårdsvænget 21 > 8362 Hørning > Tlf. +45 2962 7576 > Web: www.silverbullet.dk > -----Original Message----- > From: raulvk [mailto:[EMAIL PROTECTED] > Sent: 10. september 2008 19:56 > To: camel-user@activemq.apache.org > Subject: Synchronous/asynchronous bridge > > > Hi, > > I am using Camel embedded in ServiceMix via the servicemix-camel service > engine. > > I need to implement the following routing scenario: > > > HTTP Consumer BC ---> Camel ---> Transformation --> HTTP Provider BC > /|\ | > |______________ | > > > Basically, I receive a SOAP request through an HTTP endpoint in ServiceMix > and it gets directed to Camel. As soon as Camel receives it, it should > immediately return back a fixed response (<Response>OK</Response>), and > then > it should invoke an XSLT Transformer, and should finally send the > transformed message to the HTTP Provider. > > I am OK with the bit where I have to use a pipeline, but I don't > understand > how to return the response half-way through the routing flow. > > Could someone help me with this, please? > > Thanks a lot! > > -- > View this message in context: > http://www.nabble.com/Synchronous-asynchronous-bridge-tp19415072s22882p19415072.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > > -- View this message in context: http://www.nabble.com/Synchronous-asynchronous-bridge-tp19415072s22882p19432301.html Sent from the Camel - Users mailing list archive at Nabble.com.