With the transactional JMS component, jmstx
, you can define a
transactional route written in Java DSL.
Note | |
---|---|
It is also possible to define the route using Spring XML syntax. |
To define a route using the transactional JMS component, jmstx
,
perform the following steps:
Define a route in the Java domain specific language (DSL). Using your favorite text editor, open the file,
tx-jms-router/src/main/java/tutorial/MyRouteBuilder.java
. Edit the body of theMyRouteBuilder.configure()
method, discarding the existing route and replacing it with the following code:public class MyRouteBuilder extends SpringRouteBuilder { ... public void configure() { from("file:src/data?noop=true") .convertBodyTo(String.class) .to("jmstx:queue:giro"); from("jmstx:queue:giro") .to("jmstx:queue:credits") .to("jmstx:queue:debits") .process(new Processor() { public void process(Exchange exchange) throws Exception { // should be printed n times due to redeliveries System.out.println("exchange = " + exchange); // force rollback throw new Exception("test"); } }); } ... }
Near the top of the
MyRouteBuilder.java
file, add the requisite import statements, as follows:// Java ... import org.apache.camel.Processor; import org.apache.camel.Exchange; ...