How to know the value of a variable from another pool ?

1
0
-1

Hi,

Is it possible to know the value of a variable that is in a Pool A from a task in a Pool B ?

I have a variable in my process A that changes value often. And my process B needs sometimes to know the value of this variable.

Maybe I can do that with the process Api.

Thanks in advance for your help.

Comments

Submitted by rahmi.hichem on Thu, 08/07/2014 - 15:40

Hello,

You can know the value of your variable at any moment , you have juste to use "Send message event" (In ur process where your variable gets her different values) and catch it in the other process with "Receive message event"

Submitted by yannick.lombardi on Thu, 08/07/2014 - 15:52

The process A (where the variable is) doesn't know when the process B want to know the value. So I can't do that. They are not synchronized.

This is the process B that need to read the value in process A.

Submitted by haris.subasic on Thu, 08/07/2014 - 15:52

I would go for the API, since you can invoke it "on demand". http://documentation.bonitasoft.com/javadoc/api/6.3/org/bonitasoft/engin...

Submitted by yannick.lombardi on Thu, 08/07/2014 - 15:58

I also found this function a few minutes ago. Now I search how to know the process ID.

EDIT : I think that Process A can send its Instance ID when the other processes begin.

Submitted by francois.chevresson on Thu, 08/07/2014 - 16:06

Hi,

You need some kind of correlation key. Do you have multiple process A and B instances running at the same time? Are process A and B started independently or one after another?

Submitted by yannick.lombardi on Thu, 08/07/2014 - 16:11

Process A is unique. Process A start before all the other process. Process B is multiple and is started independently some time after A.

Submitted by francois.chevresson on Thu, 08/07/2014 - 23:35

if Process A is unique, the easiest might be to: - retrieve the processDefinitionID:

final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 5);
        builder.filter(ProcessDeploymentInfoSearchDescriptor.NAME, "My_ProcessA");
        final SearchResult<ProcessDeploymentInfo> searchRes = getProcessAPI().searchProcessDeploymentInfosStartedBy(userId, builder.done());
Submitted by yannick.lombardi on Fri, 08/08/2014 - 09:22

Thanks francois. I find a solution based on your idea. Here is my code :

import org.bonitasoft.engine.search.*;
import org.bonitasoft.engine.bpm.process.ProcessInstance;
import org.bonitasoft.engine.bpm.process.ProcessInstanceSearchDescriptor;

// I search the process A
final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 5);
builder.filter(ProcessInstanceSearchDescriptor.NAME, "My_ProcessA");
final SearchResult<ProcessInstance> searchRes = apiAccessor.getProcessAPI().searchProcessInstances(builder.done());

// The process is unique so it is the first one in the result
Long processId = searchRes.getResult().get(0).getId();

// My variable is a boolean
Boolean test = apiAccessor.getProcessAPI().getProcessDataInstance("My_VariableInA", processId).getValue();
No answers yet.
Notifications