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:

  1. final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 5);
  2. builder.filter(ProcessDeploymentInfoSearchDescriptor.NAME, "My_ProcessA");
  3. 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 :

  1. import org.bonitasoft.engine.search.*;
  2. import org.bonitasoft.engine.bpm.process.ProcessInstance;
  3. import org.bonitasoft.engine.bpm.process.ProcessInstanceSearchDescriptor;
  4.  
  5. // I search the process A
  6. final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 5);
  7. builder.filter(ProcessInstanceSearchDescriptor.NAME, "My_ProcessA");
  8. final SearchResult<ProcessInstance> searchRes = apiAccessor.getProcessAPI().searchProcessInstances(builder.done());
  9.  
  10. // The process is unique so it is the first one in the result
  11. Long processId = searchRes.getResult().get(0).getId();
  12.  
  13. // My variable is a boolean
  14. Boolean test = apiAccessor.getProcessAPI().getProcessDataInstance("My_VariableInA", processId).getValue();
No answers yet.
Notifications