Esteban Robles Luna on Tuesday, February 15, 2011

Activiti + Mule ESB – Part 1

13

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.

No related posts.

Interested in 3 days of knowledge sharing, hands-on labs, industry focused sessions, and plenty of networking? Register for the premier integration event, CONNECT London »

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

Activiti + Mule ESB – Part 2 | The refuge February 20th, 2011, 12:51 pm

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

Alejandro March 3rd, 2011, 8:34 am

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?

Greetings.-

Alejandro March 4th, 2011, 6:23 am

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
[Mule_Home]\apps\[appName]\classes\com\picturerequest\

bye!

Patrick March 16th, 2011, 9:01 am

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.

Esteban Robles Luna March 16th, 2011, 9:43 am

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?
Cheers

Patrick March 17th, 2011, 12:59 am

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.

From the Mule’s Mouth » New version of the Activiti module released! May 2nd, 2011, 4:32 am

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

test September 27th, 2011, 12:22 am

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?

john September 27th, 2011, 5:33 am

How to authenticate user in mule before starting proces ?

john December 1st, 2011, 6:02 pm

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

as

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

Building OpenSource SOA | Tecnología 20:20 Mobile January 29th, 2012, 9:23 am

[...] 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 [...]

azaz December 4th, 2012, 10:07 pm

Hi,

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

Sriram July 18th, 2013, 5:26 am

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?

Thanks,
Sriram.

Leave a Comment