Hi,
Here is the solution I found, which seems to work ... in a class which
extends RouteBuilder :
@Override
public RoutesDefinition configureRoutes(ModelCamelContext context)
throws Exception {
super.configureRoutes(context);
for (RouteDefinition routeDef : this.getRouteCollection().getRoutes()){
boolean isTransacted = false;
List<OnExceptionDefinition> onExceptions = new
ArrayList<OnExceptionDefinition>();
List<InterceptDefinition> intercepts = new
ArrayList<InterceptDefinition>();
List<InterceptFromDefinition> interceptFromDefinitions = new
ArrayList<InterceptFromDefinition>();
List<InterceptSendToEndpointDefinition>
interceptSendToEndpointDefinitions = new
ArrayList<InterceptSendToEndpointDefinition>();
List<OnCompletionDefinition> onCompletions = new
ArrayList<OnCompletionDefinition>();
for (ProcessorDefinition output : routeDef.getOutputs()) {
log.info(output.getClass().getName());
if (output instanceof org.apache.camel.model.PolicyDefinition){
log.debug("ban : route " + routeDef.getId() + " was
already
defined with transactional mode set-up : ");
isTransacted = true;
}
}
if (isTransacted){
continue;
}
for (ProcessorDefinition output : routeDef.getOutputs()) {
if (output instanceof OnExceptionDefinition) {
onExceptions.add((OnExceptionDefinition)output);
continue;
}
if (output instanceof InterceptFromDefinition) {
interceptFromDefinitions.add((InterceptFromDefinition)output);
continue;
}
if (output instanceof
InterceptSendToEndpointDefinition) {
interceptSendToEndpointDefinitions.add((InterceptSendToEndpointDefinition)output);
continue;
}
if (output instanceof InterceptDefinition) {
intercepts.add((InterceptDefinition)output);
continue;
}
if (output instanceof OnCompletionDefinition) {
onCompletions.add((OnCompletionDefinition)output);
continue;
}
}
if (!isTransacted){
if
(!routeDef.getOutputs().contains("PolicyDefinition")){
TransactedDefinition td = new TransactedDefinition();
td.setType(TransactedPolicy.class);
td.setRef("PROPAGATION_REQUIRES_NEW");
routeDef.addOutput(td);
log.info("BAn : default transacted mode set-up");
RouteDefinitionHelper.prepareRoute(context, routeDef,
onExceptions,
intercepts, interceptFromDefinitions, interceptSendToEndpointDefinitions,
onCompletions);
}
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/Is-there-a-clean-way-to-default-route-transaction-mode-at-the-route-builder-level-tp5745728p5745946.html
Sent from the Camel - Users mailing list archive at Nabble.com.