Hello,
I`m using Camel ver. 2.10.1 and my route is not started when I use
AdviceWith within RouteBuilder.
Here is my context:
<bean id="routeBuilder" class="my.test.RouteBuilder"/>
<camel:camelContext id="myContext">
<camel:routeBuilder ref="routeBuilder" />
<camel:route id="route1">
...
<camel:to uri="direct:route2"/>
</camel:route>
<camel:route id="route2">
...
// some CXFRS calls...
</camel:route>
</camel:camelContext>
and route builder java code:
public class RouteBuilder extends org.apache.camel.builder.RouteBuilder {
private static final String DEVEL_PROPERTY = "env";
private static final String DEVEL_VALALUE = "devel";
@Override
public void configure() throws Exception {
String property = System.getProperty(DEVEL_PROPERTY);
if (property != null && property.matches(DEVEL_VALALUE)) {
getContext().addStartupListener(new StartupListener() {
@Override
public void onCamelContextStarted(CamelContext context,
boolean alreadyStarted) throws Exception {
Route route = context.getRoute("route2");
if (route != null) {
RouteDefinition routeDefinition =
route.getRouteContext().getRoute();
routeDefinition.adviceWith((ModelCamelContext)
context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("cxfrs://*").skipSendToOriginalEndpoint().to("stream:out");
}
});
} else {
log.warn("Missing route 'route1' in context");
}
}
});
}
}
}
Problem is in method adviceWith() (where I add interceptSendToEndpoint()).
At the end of method adviceWith() should be merged route restarted.
Unfortunately the route is not started (I get CamelExchangeException: No
consumers available on endpoint...) because
DefaultCamelContext.shouldStartRoutes() return false.
So how can I use adviceWith to start merged route?
Why I need this? Because on development environment I don`t want to send
Exchange message to CXFRS component. Instead of I want only print out
("stream:out") the message.
--
View this message in context:
http://camel.465427.n5.nabble.com/adviceWith-does-not-start-merged-route-tp5723664.html
Sent from the Camel - Users mailing list archive at Nabble.com.