AnsweredAssumed Answered

Unable to advice routes holding activiti consumers

Question asked by mteira on Mar 27, 2014
Latest reply on Apr 23, 2014 by mteira
Hi there,

I'm new to Activiti, evaluating it as a potential replacement solution for our BPM engine. 
While checking some use cases I've hit a problem trying to write a test case that tries to advice a camel route with an activiti consumer. The environment was:
- Activiti 5.14
- Camel 2.11
- JDK 1.6
- Test case using a spring context, declaring a camel context to scan a package for routes.

The issue seems to be related to this sequence of operations:
- The spring context is setup, creating the camel context, which sets up the discovered routes.
- The test case is started, and the camel context is instructed to advice the route
- The camel context tries to refresh the route, to perform the required modifications
- Starting the route again, throws the following exception:

java.lang.RuntimeException: Activit consumer already defined for activiti://TestProcess:sender!
   at org.activiti.camel.ActivitiEndpoint.addConsumer(
   at org.activiti.camel.ActivitiConsumer.doStart(
   at org.apache.camel.impl.DefaultCamelContext.startService(
   at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(
   at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(
   at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(
   at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(
   at org.apache.camel.impl.DefaultCamelContext.startRouteService(
   at org.apache.camel.impl.DefaultCamelContext.startRoute(
   at org.apache.camel.model.RouteDefinition.adviceWith(
   at camel.test.AdviceActivitiConsumerRouteTest.testAdviceOnActivitiRoute(

Checking the code in activiti-camel, I understand that on start, the ActivitiConsumer sets himself as the consumer for the ActivitiEndpoint. However, no overloading of the doStop() method is made, and so, a stop/start sequence on the consumer leads to the Endpoint throwing that exception since a consumer is already setup.

In my understanding, this prevents a route with an activiti consumer to be restarted and hence, to be adviced in case it was already started. I've tried a little modifications to the ActivitiConsumer to override doStop() and remove the consumer from the endpoint, and it seems to work properly. I'm adding below some analysis on the issue I've made, to your consideration (and also the patch).

Should I open a Jira issue for this or could be something related to a bad usage from my side?

Best regards,


Following a simple test case to prove it (it throws the aforementioned exception)

public class AdviceActivitiConsumerRouteTest {
   private ModelCamelContext camelContext;
    public void testAdviceOnActivitiRoute() throws Exception {

             new AdviceWithRouteBuilder() {
               public void configure() throws Exception {

Where the route is anything holding an activiti consumer, like:

public class CamelTestRoute extends RouteBuilder {

   public void configure() throws Exception {

The spring context has nothing special other than the standard configuration. Only a camel context to scan a given package for routes:

   <camelContext id="camelContext" xmlns="">