camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raulvk <raul.kripal...@atosorigin.com>
Subject RE: Synchronous/asynchronous bridge
Date Thu, 11 Sep 2008 10:54:09 GMT

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:ci@silverbullet.dk] 
> 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:raul.kripalani@atosorigin.com] 
> 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.


Mime
View raw message