Activiti + Mule ESB – Part 1

February 15 2011

13 comments 0

We are pleased to announce Mule 3 Activiti support. We’re very happy to be working with the Activiti team and see a lot of value for our community using Mule and Activiti together. I already discussed why BPM and ESB need to work together and two different uses of ESBs with BPM. Today I am going to present a real world example.

For those that may not be familiar, Actiiviti is an open source modeling tool and runtime, founded by Alfresco and developed with other open source companies.

Getting Started

My example application uses Mule ESB and Activiti allowing users to view low-resolution images and request a high-resolution version that needs to be approved by a human participant (similar to Stock.XCHNG). Mule will handle the creation of the Activiti process and will take care of exposing it as a service. Activiti will take care of orchestrating the process that requires a user task (approval).

This short demo will show you what we are building here:

Mule will handle the picture requests using a HTTP endpoint (Step 1 of Fig. 1) and creating an Activiti process for it using Mule’s activiti module (Step 2 of Fig. 1). The process is the responsible of controlling the business logic under the picture approval. When the request is approved we need to charge the user with some amount of money; as we already have an existing component in our organization for that purpose we simply expose it as a Web service inside mule. Therefore Activiti calls this Web service to charge the user and also to notify him that the request has been approved (Step 3 of Fig. 1).

Fig. 1. Application overview

Fig. 1. Application overview

In this part of the post we will look in detail on how we handle the requests using Mule ESB to start the approval process handled with Activiti.

Mule application

The first step is to build our Mule application; for simplicity the application will show a set of predefined low resolution mule images that users can request and it won’t handle authentication. In our Home page we show the images as shown in Fig. 2.

Fig. 2. Exemplar web application

Fig. 2. Exemplar web application

When the user clicks on the request image button, it performs a request to a URL that will be handled by Mule. A flow inside Mule handles this HTTP request by creating a new process in Activiti and returning the ‘Success’ string. As the process needs the user and the image as variables, we will need a Script component that creates the parameters map to push them inside the Activiti process. Look at the script:component of the following flow:

Now we are ready from the Mule side; you can take a look at the Mule configuration by downloading the full project from here

Activiti stub configuration

For part 1 of this series we just want to create a simple version of the Activiti process. To make sure everything works fine; therefore we will create a stub process that shows the variables that we have set from the Mule’s side. The process will prompt a form that shows the variables as shown in Fig. 3.

Fig. 3. Stub approval of our picture request

Fig. 3. Stub approval of our picture request

The definition of the process is pretty simple and is shown next; basically the process prompts a form that will show the variables:

The form is pretty simple and simply prints the variables inside a paragraph:

Next, you need to zip both files and publish them in Activiti to make them available using Activiti-probe. If you haven’t done this before please look at the Activiti’s user guide.

We are done with this part, if you need to take a look at the configuration details of Mule please download them from here. You can start the project by setting your MULE_HOME variable and running mvn clean install; the Mule application will be available at: http://localhost:8999/. Don’t forget to publish the Activiti deployment zip file under the activiti-picture-example directory.

The Activiti’s process will be a stub for now and we will complete it in part 2.

We'd love to hear your opinion on this post

13 Responses to “Activiti + Mule ESB – Part 1”

  1. […] all we need to do is extend the previous Mule configuration from part 1 and add a new flow exposing the Web […]

  2. Hi, by extending the configuration and add second flow throws an error:

    ERROR 2011-03-02 20:09:04,706 [WrapperListener_start_runner] org.mule.config.spring.SpringXmlConfigu
    rationBuilder: Configuration with “org.mule.config.spring.SpringXmlConfigurationBuilder” failed.
    org.mule.api.lifecycle.InitialisationException: Error creating bean with name ‘chargeAccount’: Canno
    t create inner bean ‘(inner bean)’ of type [org.mule.module.cxf.config.WebServiceFactoryBean] while
    setting bean property ‘messageProcessors’ with key [0]; nested exception is org.springframework.bean
    s.factory.BeanCreationException: Error creating bean with name ‘(inner bean)’: Initialization of bea
    n failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert pro
    perty value of type ‘java.lang.String’ to required type ‘java.lang.Class’ for property ‘serviceClass

    anyone know the reason?


  3. Sorry, is my mistake… i did wrong the deploy. A succesful deployment would be as follows:

    put the class ChargeService and ChargeServiceImpl on the path


  4. I have a problem to pass the hashmap to the activiti-outbound-endpoint. It does not recognize the hashmap and send a pure json string to the activiti server. Is there any change in 3.1.1 and activiti 5.3?

    If I enter the id as a message payload in mule everything works fine, just the hashmap example wont work.

  5. Hi Patrick,
    I haven’t tested the module with Activiti 5.3 yet.
    Also, the module has been moved to muleforge; did you switch to this version?

  6. Yep,

    I´ve used the muleforge version with maven. So it´s actually some kind of working but now I don´t know how to pass a few parameters to the process without the hashmap.

  7. […] module allows you to control your Activiti instance from Mule as we shown here: Activiti + Mule part 1 and part […]

  8. When i start the process from Explorer, i can see the instance in ‘My instances’, but if i start the process from the mule app the process is started but i can’t see the process instance in ‘My instances’ :

    Map map = new HashMap()
    map.put(“processDefinitionId”, message.getProperty(“processDefinitionId”))
    map.put(“businessKey”, message.getInboundProperty(“id”))
    map.put(“user”, message.getProperty(“user”))
    return map

    any suggestions?

  9. How to authenticate user in mule before starting proces ?

  10. hi, nice post. im trying to do this test but im using latest versions of both mule and activity. how can i call


    p.s. im very new to these two technologies.

  11. […] ESB as possible, and to ease the process design, we started to search for new possibilities. And this series of posts by Esteban Robles made myself take a step forward to this […]

  12. Hi,

    How can i integrate mule in activiti 5.10 version, can u send me the link or give me the demo example!!!

  13. Hi,
    The bpmn20.xml file used in the above sample doesnt have DI information and thus cannot be used in the Acitivi Explorer using Import.Can you kindly post a sample file which has DI information in the xml file?