Hi,
I am using camel to read from multiple uri and throttel into same processor.
Following is the configuration used
from(this.getUris())
.transacted("jmsRequired")
.choice()
.when(this.predicate).to("bean:camelDataProcessor?method=execute")
.otherwise()
.throttle(maxTps)
.timePeriodMillis(1000)
.asyncDelayed()
.to(ExchangePattern.InOnly,
"bean:camelDataProcessor?method=execute").end();
"this.getUris" returns array of uris somrthing like
sjms:queue:queueA,sjms:queue:queueB and so on.
sjms is an object of org.apache.camel.component.sjms.SjmsComponent.
Since getUris get array of queues from database , camel has to be reloaded
once, new queues are added in database.
To reload, I am stopping and removing the routes as follows ::
public Boolean restart() {
Boolean result = false;
try {
this.queueExtractor.init();
List<Route> routeRemoveList = new ArrayList<Route>();
for (Route route : this.camelContext.getRoutes()) {
routeRemoveList.add(route);
}
String routeId = "";
for (Route route : routeRemoveList) {
routeId = route.getId();
this.camelContext.stopRoute(route.getRouteContext().getRoute());
this.camelContext.stopRoute(routeId);
this.camelContext.removeRoute(routeId);
}
this.camelContext.addRoutes(this);
InteractionsUtil.pause(60000);
result = true;
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return result;
}
Now say, my initial number of queues are 5 and newly added are another 5. So
total of 10 from getUris method.
When I call this restart method, it stops one of the 5 older consumers but 4
consumers remains as it is.
I checked the routeId, it always comes as "Route 1", even if it has multiple
uris.
Please let me know , what wrong I am doing that? I need to stop all
consumers and start the context as fresh.
Happy Coding
Sabyasachi
--
View this message in context:
http://camel.465427.n5.nabble.com/Cannot-stop-multiple-route-tp5783094.html
Sent from the Camel - Users mailing list archive at Nabble.com.