How to distinguish between Activity_Started Events of the same Activity ID?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

How to distinguish between Activity_Started Events of the same Activity ID?

Hi,

I'm trying to catch all the events raised in consequence of starting or completing of serviceTask Activities.

Event types: ACTIVITY_STARTED, ACTIVITY_COMPLETED.

My system is integrated with Activiti through ActivMQ by defining the property "typedEventListeners" and implementing a class that catch the events of specific types.

My system is creating an System-Entity when activity started in Activiti and closing this Entity when the activity is completed.

It saves 3 Parameters:

  • process Definition ID
  • Process Instance ID
  • Activity ID

In case my process contains a loop, means an activity occur more then once during the process execution -

I need to be able to distinguish between Activity_Started Events of the same ActivityID. So I can create in my system, for each event, an Entity with unique number, so when the Activity_Completed Event will arrive I could know which entity should be closed. 

Can you please help me deal with this problem?

Thank you,

Maayan.

6 Replies
Highlighted
Established Member II

Re: How to distinguish between Activity_Started Events of the same Activity ID?

Maayan,

I don't have an answer for you right now - but I'm digging a little bit deeper.

-JEarles

Highlighted
Active Member II

Re: How to distinguish between Activity_Started Events of the same Activity ID?

Thank you.
I keep trying to find an appropriate solution.
Maayan

Highlighted
Intermediate

Re: How to distinguish between Activity_Started Events of the same Activity ID?

Ok, so you listener will (must) implement the ActivitiEventListener interface which gives you access to the execution context (DelegateExecution).
Therefore, you have access the process instance variables.
I would add a simple loop counter (if you use a serial multi-instance loop this is provided for you) as a process variable and then inside your listener add this to the Activity ID (e.g. MyTask:2).

Regards,

Greg

Highlighted
Active Member II

Re: How to distinguish between Activity_Started Events of the same Activity ID?

Hi Greg,

First of all, thank you for your answer.

One problem with this solution-

I cannot be sure there will be a counter on the loop and if so, I cannot be sure what is the counter variable name.

The process model is defined by different people and I need to be able to handle each case without making any assumption about the process model flow or variables.

 

Is it sound like something possible?

 

Thank you,

Maayan

Highlighted
Intermediate

Re: How to distinguish between Activity_Started Events of the same Activity ID?

Yeah, if you cannot control the definition of the processes, and you don't even know if a loop is in the model, then there's not a whole helluva lot you can do.

The best thing I could suggest would be to add a parse handler to the engine and add a listener that handles the logic to make each task name unique.

The reality here is BPM is about controlling your processes, if you have no controls in place in the authoring and deployment side of things, you really aren't doing BPM.

Greg

Highlighted
Active Member II

Re: How to distinguish between Activity_Started Events of the same Activity ID?

Hi,

The suggestion of adding a parse handler to the engine and adding a listener that handles the logic to make each task name unique is sounds like somthing that can be helpful.

Thanks alot!

Maayan