-
1. Re: jBPM 5: how save a ProcessInstance ?
eaa May 27, 2011 7:44 AM (in response to jbpm5learner)In jBPM5, processInstance is saved automatically when it reaches a wait-state. There is no way to persist it on-demand.
You can find more information about process persistence in the documentation manual:
-
2. Re: jBPM 5: how save a ProcessInstance ?
jbpm5learner May 30, 2011 3:30 AM (in response to eaa)The fact that the processInstance is automatically saved may be convenient. But doing some investigation on the jbpm5-source I found some interesting code examples that may offer explicit saving of a ProcessInstance:
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa");
JpaProcessPersistenceContextManager procPersistMgr = new JpaProcessPersistenceContextManager(env););
persistContext.persist(procInfo);
The "ProcessPersistenceContext" allows to persist a so-called ProcessInstanceInfo-object. This object contains a ProcessInstance-object. Are you consequently sure that there is no way to persist ProcessInstance on-demand ?
-
3. Re: jBPM 5: how save a ProcessInstance ?
jbpm5learner May 30, 2011 4:39 AM (in response to jbpm5learner)Sorry, my code example was incomplete - this is the correction of how to create the env-object:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
-
4. Re: jBPM 5: how save a ProcessInstance ?
amin-mc Nov 3, 2011 5:25 AM (in response to jbpm5learner)Hi
I have a use case where I will need to update the process instance variables after the process engine has reached teh safe point. I then need to persist the updated process instance. Is the above the only approach? Is there no other API available?
Thanks
-
5. Re: jBPM 5: how save a ProcessInstance ?
salaboy21 Nov 3, 2011 8:53 AM (in response to amin-mc)What exactly are you trying to achieve? why do you need to modify the process variables after a wait state?
I mean, if you reach a wait state it means that you are waiting for some external executions, that external service will return some that that will be feed into the process engine that will be in charge of mapping those results with the process variables. I don't see any case where you need to update externally the process variables.
Cheers
-
6. Re: jBPM 5: how save a ProcessInstance ?
amin-mc Nov 3, 2011 8:59 AM (in response to salaboy21)Hi
Basically I need to get to a wait state...make a call to an external service which returns some value which I then needs to be mapped back to a process instance variable.
-
7. Re: jBPM 5: how save a ProcessInstance ?
amin-mc Nov 3, 2011 1:24 PM (in response to amin-mc)Hi
I would really appreciate if some could advise on this...i have an important usecase that requires the ability to do this.
Thanks
-
8. Re: jBPM 5: how save a ProcessInstance ?
calca Nov 4, 2011 7:41 AM (in response to amin-mc)Well, I think you could model it with an event. After the process reached a wait state, you can have a catching event node, so when you get the response from the external service, you can make a session.signalEvent("theevent", eventData) and update the process variables you need inside the process.
Anyway, it would be good to know a bit more about your business requirement in order to give a good advice.
Regards,
Demian
-
9. Re: jBPM 5: how save a ProcessInstance ?
amin-mc Nov 5, 2011 5:12 AM (in response to calca)Hi
I'm not sure if the event mechanism would work. Essentially we have to accumulate operations to a remote service during the execution of the process instance. Once the process reaches a safe point I need to flush the accumulated operations to the external service. Once the external service returns a result I have to go back and update the process instance variables so the process instance variables are up to date during the next execution.
Originally each of my custom service handlers would make individual calls and get a response and update the process instance but this approach is not efficient and causes some transaction issues (long and difficult story to explain ).
Thanks