...
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
...
The list of supported transaction policy names is: PROPAGATION_NEVER
, PROPAGATION_NOT_SUPPORTED
, PROPAGATION_SUPPORTS
, PROPAGATION_REQUIRED
, PROPAGATION_REQUIRES_NEW
, PROPAGATION_NESTED
, PROPAGATION_MANDATORY
.
Transactional error handler
Camel CDI provides a transactional error handler that extends the redelivery error handler, forces a rollback whenever an exception occurs and creates a new transaction for each redelivery. Camel CDI provides the CdiRouteBuilder
class that exposes the transactionErrorHandler
helper method to enable quick access to the configuration, e.g.:
Code Block | ||
---|---|---|
| ||
class MyRouteBean extends CdiRouteBuilder {
@Override
public void configure() {
errorHandler(transactionErrorHandler()
.setTransactionPolicy("PROPAGATION_SUPPORTS")
.maximumRedeliveries(5)
.maximumRedeliveryDelay(5000)
.collisionAvoidancePercent(10)
.backOffMultiplier(1.5));
}
} |
Auto-configured OSGi integration
...