cancel
Showing results for 
Search instead for 
Did you mean: 

Pass an object between two tasks in an activiti process

akashraveendran
Champ in-the-making
Champ in-the-making
Hi all,

In my bpmn I have two service tasks, both of them are functions to call my service class functions.
The below is my bpmn file code.

   <serviceTask id="updateContact" activiti:expression="#{printer.updateContact()}" />
   <sequenceFlow id="flow3" sourceRef="updateContact" targetRef="readContact" />
   <serviceTask id="readContact" activiti:expression="#{printer.readContact()}" />

The printer variable inside expression is an object of my class Printer which contains updateContact() and readContact() functions. Now what I want is to pass an object from updateContact serviceTask to readContact serviceTask. I saw examples of passing objects to functions using delegate but I want to know if we can pass an object between two serviceTasks? If yes, then how? I am new to Activiti so please help me out with this.
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

org.activiti.engine.test.bpmn.servicetask.ServiceTaskVariablesTest

in activiti source.

Regards
Martin

akashraveendran
Champ in-the-making
Champ in-the-making
Hi Martin,

Thank you for your quick reply. I am looking into the source code you suggested.

akashraveendran
Champ in-the-making
Champ in-the-making
Hi Martin,

From the examples I saw, I understand that we will have to use execute method to implement the passing of objects between the service task functions. But I want to use a function with different name like update() for update and read() for read. So how can we use custom methods along with using Execution object?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I do not understand the question.

Regards
Martin

akashraveendran
Champ in-the-making
Champ in-the-making
Hi Martin,

Actually my requirement is to pass a pojo class object from one service task( say update ) to another service task( say read ). I have a JavaDelegate implementing class for both the service tasks. Now I want to set the pojo class from the update class and access it in read class. I had a look at the code you told me to look into but still I was not able to get things clear.

I was getting an error of this sort : ActivitiPerson is the pojo class I was talking about with two string fields firstName and lastName.
org.activiti.engine.ActivitiException: couldn't find a variable type that is able to serialize com.xxx.yyy.zzz.ActivitiPerson@5bf8581a.

This is the code in my bpmn for the update service task :
serviceTask id="updateContact" activiti:delegateExpression="${callUpdateContact}"
sequenceFlow id="flow3" sourceRef="updateContact" targetRef="readContact"
serviceTask id="readContact" activiti:delegateExpression="${callReadContact}"

Can you please help me with this? I am actually stuck with this from a long time

akashraveendran
Champ in-the-making
Champ in-the-making
Hi Martin,

It was a subtle mistake on my side. I didnt make the java pojo class serializable. Its working well after I made the pojo  class Serializable. Thank you for all your support.