You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Punnoose, Roshan A." <ra...@nsa.gov> on 2008/09/09 16:56:33 UTC

Issue with the ProducerTemplate

I tried searching on this problem, but couldn't come up with anything.
Basically, i am using Spring and Camel Annotations to inject a
ProducerTemplate into a class and use the method requestBody to send an
object to a certain endpoint:
 
producerTemplate.requestBody("direct:workflow", obj);
 
Now if the route specified by "direct:workflow" throws an exception, i
want it to bubble that exception up to the class invoking the
ProducerTemplate. Instead, the ProducerTemplate returns the same Object
(obj) that I used as a parameter. How can I get it to throw the correct
exception instead?
 
Roshan

RE: Issue with the ProducerTemplate

Posted by "Punnoose, Roshan A." <ra...@nsa.gov>.
Not sure if I am going down the wrong path, but I tried this too: (had
to fat finger this, so hopefully it compiles)

Endpoint endpoint = camelContext.getEndpoint("direct:workflow");
Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
exchange.getIn().setBody(obj);
CamelTemplate<Exchange> camelTemplate = new
CamelTemplate<Exchange>(camelContext, endpoint);
Exchange out = camelTemplate.send(exchange);


The problem becomes that even though I have a throwFault(...) in the
route specified, the CamelTemplate does not return this in the outgoing
Exchange. The exception field and the fault field are not populated. Am
I doing this wrong?

P.s. I am using Camel 1.4.0

Roshan

-----Original Message-----
From: James Strachan [mailto:james.strachan@gmail.com] 
Sent: Tuesday, September 09, 2008 11:09 AM
To: camel-user@activemq.apache.org
Subject: Re: Issue with the ProducerTemplate

2008/9/9 Punnoose, Roshan A. <ra...@nsa.gov>:
> I tried searching on this problem, but couldn't come up with anything.
> Basically, i am using Spring and Camel Annotations to inject a 
> ProducerTemplate into a class and use the method requestBody to send 
> an object to a certain endpoint:
>
> producerTemplate.requestBody("direct:workflow", obj);
>
> Now if the route specified by "direct:workflow" throws an exception, i

> want it to bubble that exception up to the class invoking the 
> ProducerTemplate. Instead, the ProducerTemplate returns the same 
> Object
> (obj) that I used as a parameter. How can I get it to throw the 
> correct exception instead?

Ooh, this looks like a bug :).

I've raised an issue for this
https://issues.apache.org/activemq/browse/CAMEL-885
--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Issue with the ProducerTemplate

Posted by James Strachan <ja...@gmail.com>.
2008/9/9 Punnoose, Roshan A. <ra...@nsa.gov>:
> I tried searching on this problem, but couldn't come up with anything.
> Basically, i am using Spring and Camel Annotations to inject a
> ProducerTemplate into a class and use the method requestBody to send an
> object to a certain endpoint:
>
> producerTemplate.requestBody("direct:workflow", obj);
>
> Now if the route specified by "direct:workflow" throws an exception, i
> want it to bubble that exception up to the class invoking the
> ProducerTemplate. Instead, the ProducerTemplate returns the same Object
> (obj) that I used as a parameter. How can I get it to throw the correct
> exception instead?

Ooh, this looks like a bug :).

I've raised an issue for this
https://issues.apache.org/activemq/browse/CAMEL-885
-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com