You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dunnlow <du...@yahoo.com> on 2012/06/06 22:16:31 UTC
How to force rollback in spring DSL route?
Hi, I have a transacted route in Spring DSL that calls a service (via HTTP
post). I want to examine the response from that service and force a
rollback depending on the returned value. Basically something like:
<route>
<from uri="jpa:com.MyBean"/>
<transacted/>
<setHeader
headerName="CamelHttpMethod"><constant>POST</constant></setHeader>
<setHeader headerName="charset"><constant>utf-8</constant></setHeader>
<setHeader
headerName="CONTENT_TYPE"><constant>test/xml</constant></setHeader>
<to uri="http4://196.12.34.54:2020"/>
<choice>
<when>
<simple>${header.CamelHttpResponseCode} != 202</simple>
*(( Roll Back the Transaction ))*
</simple>
</when>
</choice>
</route>
What is the right way to force a rollback?
Thanks for any insight,
-J
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-force-rollback-in-spring-DSL-route-tp5714090.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to force rollback in spring DSL route?
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 7, 2012 at 4:11 PM, dunnlow <du...@yahoo.com> wrote:
> Thanks Claus. And in the vein of "teach a man to fish..." where would one
> find information about the <rollback> command (is it safe to assume that if
> .rollback() exists there is a Spring counterpart)?
>
>
If you have a good editor, you just press ctrl + space and it shows a list
of methods / xml tags you can use.
In XML there is a XSD schema that defines the DSL. And In Java, its ...
just java code.
> Also, I had considered throwing an exception but was not sure how to do
> that
> in Spring DSL. Creating a bean to throw it seemed ugly, but it just
> occurred to me I could probably add a <javascript>throw
> "rollback"</javascript>. What is the cleanest way to throw an exception in
> Spring DSL?
>
>
Thanks again, -J
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-force-rollback-in-spring-DSL-route-tp5714090p5714129.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: How to force rollback in spring DSL route?
Posted by dunnlow <du...@yahoo.com>.
Thanks Claus. And in the vein of "teach a man to fish..." where would one
find information about the <rollback> command (is it safe to assume that if
.rollback() exists there is a Spring counterpart)?
Also, I had considered throwing an exception but was not sure how to do that
in Spring DSL. Creating a bean to throw it seemed ugly, but it just
occurred to me I could probably add a <javascript>throw
"rollback"</javascript>. What is the cleanest way to throw an exception in
Spring DSL?
Thanks again, -J
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-force-rollback-in-spring-DSL-route-tp5714090p5714129.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to force rollback in spring DSL route?
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 6, 2012 at 10:16 PM, dunnlow <du...@yahoo.com> wrote:
> Hi, I have a transacted route in Spring DSL that calls a service (via HTTP
> post). I want to examine the response from that service and force a
> rollback depending on the returned value. Basically something like:
>
> <route>
> <from uri="jpa:com.MyBean"/>
> <transacted/>
> <setHeader
> headerName="CamelHttpMethod"><constant>POST</constant></setHeader>
> <setHeader headerName="charset"><constant>utf-8</constant></setHeader>
> <setHeader
> headerName="CONTENT_TYPE"><constant>test/xml</constant></setHeader>
> <to uri="http4://196.12.34.54:2020"/>
> <choice>
> <when>
> <simple>${header.CamelHttpResponseCode} != 202</simple>
> *(( Roll Back the Transaction ))*
> </simple>
> </when>
> </choice>
> </route>
>
> What is the right way to force a rollback?
>
There is a <rollback>
Or you can throw an exception.
> Thanks for any insight,
> -J
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-force-rollback-in-spring-DSL-route-tp5714090.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen