-
1. Re: Process persistense - change WHEN it should happen!
swiderski.maciej Jun 22, 2012 12:24 PM (in response to nt2005)you could register a custom process event listener on the session that collects all information you need and keeps them in memory until you decide to persist them. And it looks like you don't need to have persistence at all or? Do you have only processes without wait states?
HTH
-
2. Re: Process persistense - change WHEN it should happen!
nt2005 Jun 23, 2012 2:33 AM (in response to swiderski.maciej)Hello Maciej,
I have only processes with my own workitems. I don´t use at the moment any usertask workitem ( I got my own or so).
The user should have the possibility to start many processes, interact with them while he is in a session. After he finished (logout) the processes should be saved like normal persistence.
What do you mean with the process event listener?
-
3. Re: Process persistense - change WHEN it should happen!
nt2005 Jun 26, 2012 11:15 AM (in response to nt2005)Hey guys,
There is a simple question, if I do something wrong.
I have many own workitems they look like this:
public class SimpleWorkItem implements WorkItemHandler { public static final String NAME = "simple"; public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { System.out.println("WorkItemHandler -> " + workItem.getId() + " - " + workItem.getName()); // do anything else manager.completeWorkItem(workItem.getId(), results); } public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { } }
After start a process and look in the sql command I noticed, that each workitems get a sql-query like:
Hibernate: insert into WorkItemInfo (creationDate, name, processInstanceId, state, OPTLOCK, workItemByteArray, workItemId) values (?, ?, ?, ?, ?, ?, ?) Hibernate: update WorkItemInfo set creationDate=?, name=?, processInstanceId=?, state=?, OPTLOCK=?, workItemByteArray=? where workItemId=? and OPTLOCK=? Hibernate: delete from WorkItemInfo where workItemId=? and OPTLOCK=?
Is this really necessary - or do I use WorkItems wrong? There was no break between execution, just ksession.startProcess(....)
-
4. Re: Process persistense - change WHEN it should happen!
swiderski.maciej Jun 27, 2012 9:02 AM (in response to nt2005)Not really following your use case. If you like to execute processes without persisting them while they are running what's the purpose of having them persisted at the end (when they are completed)? Since jbpm will remove all runtime data from db once process instance is completed...
I suggested process listeners since that is used to collect information about running processes to build up kind of history log.
If you like to have several elements enclosed in one transaction you could mark transaction boundary your self and jbpm will join that transaction instead of creating separate transactions for each command. Take a look at the documentation for more details.
HTH
-
5. Re: Process persistense - change WHEN it should happen!
nt2005 Jun 27, 2012 11:13 AM (in response to swiderski.maciej)Hey Maciej,
Thank you for your replay. At the moment I must think on my own, if that what I do is really useful. o.O
-
6. Re: Process persistense - change WHEN it should happen!
nt2005 Jun 30, 2012 7:02 AM (in response to nt2005)Hey again,
I want to manage persistence by my own. I am sure that I want this...
I know how to persistence a StatefulKnowledgeSession and a ProcessInstance with marshaller. BUT after reloading a session and process I would like to go one with the process. But I have no idea how to combine a session und process again.
Example:
StatefulKnowledgeSession ksession = getKnowledgeBase().newStatefulKnowledgeSession(); registerWorkItems(ksession); // add Workitems to the session ProcessInstance process = ksession.startProcess( "de.tud.iwm.catena.analysis.new" ); storeSession(ksession); // using marshaller storeProcess(process); // using marshaller // do anything else... // and anywhen, anywhere - reload all StatefulKnowledgeSession ksession = loadSession(); ProcessInstance process = loadProcess(); /* And now I cannot use: ksession.getWorkItemManager().completeWorkItem(....) Because the reloaded session does not know anything of the process ksession.getProcessInstance(...) does not work - understandable I was looking for somehting like: ksession.addProcess(process) */
Thanks in advance. If it makes no sense to you what I really want and do, say it please. But it is hard for me to tell you it in english. O.o German would be a bit easier.
-
7. Re: Process persistense - change WHEN it should happen!
swiderski.maciej Jul 2, 2012 9:01 AM (in response to nt2005)Hmmm, not really sure what is your use case here. Why would you like to do yourself something that is already managed by the engine (storing session and process instance information)? If you could give more requirements for it maybe I will be able to get your idea otherwise it is very difficult to follow it. Sorry German won't help me at all
Unfortunately I am not an expert in the marshalling world so can't help you much with that. But maybe there is another approach to that ...