-
1. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
salaboy21 Dec 2, 2013 12:02 PM (in response to fgiannetti)Hi,
first of all if you are using the runtimeManager you should get the Task Service from it.
About the global, that's normal, when you try to load the session again for continue working (because you have one session per process instance) the foo variable is not initialized again.
I would recommend you using a process variable instead of a global and that will be stored in the context of the process so you know that it will be always there.
HTH
-
2. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
fgiannetti Dec 2, 2013 12:07 PM (in response to salaboy21)Thanks for you reply!
I use the process variable solution temporarily until I have some more information about it. If cant have more, i keep it as final solution
Regards!
-
3. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
salaboy21 Dec 2, 2013 12:14 PM (in response to fgiannetti)Can I ask what kind of globals are you trying to set/use? Gloabls are usually external services.. so if that's the case a Global should be the answer. For that you can use globals but you need to make sure that every time before using the ksession you set the global.
-
4. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
fgiannetti Dec 2, 2013 12:35 PM (in response to salaboy21)The global is a service that contains some methods to make some business logic.
How can I get the ksession when I use the TaskService? I have the TaskService with the @Inject, so cant see where set the global variables.
Anyway, if the solution is set the global any time I use the session (not just once while creating it) I gess that the process variable solution is the best of both
Tanks!!!
-
5. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
salaboy21 Dec 2, 2013 12:44 PM (in response to fgiannetti)Don't inject the task service use this:
- RuntimeEngine engine= manager.getRuntimeEngine(ProcessInstanceIdContext.get());
- KieSession session=engine.getKieSession();
- TaskService taskService = engine.getTaskService();
Every time that you want to use the global you will need to do:
- session=engine.getKieSession();
- session.setGlobal("name", value );
-
6. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
salaboy21 Dec 2, 2013 12:44 PM (in response to salaboy21)Don't inject the task service use this:
- RuntimeEngine engine= manager.getRuntimeEngine(ProcessInstanceIdContext.get());
- KieSession session=engine.getKieSession();
- TaskService taskService = engine.getTaskService();
Every time that you want to use the global you will need to do:
- session=engine.getKieSession();
- session.setGlobal("name", value );
-
7. Re: JBPM6 - RuntimeManager @PerProcessInstance and KSession
swiderski.maciej Dec 4, 2013 3:10 AM (in response to salaboy21)guys, this is indeed missing feature in RuntimeManager that should allow to define what globals shall be injected in ksession on it's creation or load. Could you please file a jira issue for this?
In meantime, instead of using process variable for global service you could (ab)use RegisterableItemsFactory implementation to put your globals into ksession when its called to register work item handlers, listeners. Most likely globals will be part of RegisterableItemsFactory anyway so it will be a matter of mowing that code into dedicated method in that class.
HTH