...
Code Block | ||
---|---|---|
| ||
<camelContext id="foo"> <route> <from uri="..."/> <process ref="baz"/> </route> <camelContext/> |
Transaction support
Available as of Camel 2.19
Camel CDI provides support for Camel transactional client using JTA.
That support is optional hence you need to have JTA in your application classpath, e.g., by explicitly add JTA as a dependency when using Maven:
Code Block | ||
---|---|---|
| ||
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<scope>runtime</scope>
</dependency> |
You'll have to have your application deployed in a JTA capable container or provide a standalone JTA implementation.
Note |
---|
Note that, for the time being, the transaction manager is looked up as JNDI resource with the |
Transaction policies
Camel CDI provides implementation for the typically supported Camel TransactedPolicy
as CDI beans. It is possible to have these policies looked up by name using the transacted
EIP, e.g.:
Code Block | ||
---|---|---|
| ||
class MyRouteBean extends RouteBuilder {
@Override
public void configure() {
from("activemq:queue:foo")
.transacted("PROPAGATION_REQUIRED")
.bean("transformer")
.to("jpa:my.application.entity.Bar")
.log("${body.id} inserted");
}
}
|
This would be equivalent to:
Code Block | ||
---|---|---|
| ||
class MyRouteBean extends RouteBuilder {
@Inject
@Named("PROPAGATION_REQUIRED")
Policy required;
@Override
public void configure() {
from("activemq:queue:foo")
.policy(required)
.bean("transformer")
.to("jpa:my.application.entity.Bar")
.log("${body.id} inserted");
}
}
|
Transactional error handler
Auto-configured OSGi integration
...