there are reasons why i don't want to make the first node 'async'. so i kept
looking for a way to signal a process asynchronously. this is what i implemented:
a AsyncProcessSignalJob that can be saved as a jbpm-job. then the job executor finds and
executes the job as any other job.
| public class AsyncProcessSignalJob extends Job {
|
| /** The Constant serialVersionUID. */
| private static final long serialVersionUID = -8358943330005955423L;
|
| public AsyncProcessSignalJob() {
| }
|
| public AsyncProcessSignalJob(ProcessInstance processInstance) {
| this.setDueDate(new Date());
| this.setProcessInstance(processInstance);
| this.setToken(processInstance.getRootToken());
| }
|
| @Override
| public boolean execute(JbpmContext jbpmContext) throws Exception {
|
| ProcessInstance processInstance = this.getProcessInstance();
| processInstance.signal();
| jbpmContext.save(processInstance);
| return true;
| }
|
|
then i created a hibernate mapping file
|
| <hibernate-mapping auto-import="false"
default-access="field">
|
| <subclass name="foo.bar.AsyncProcessSignalJob"
| discriminator-value="P"
| extends="org.jbpm.job.Job">
|
| </subclass>
|
| </hibernate-mapping>
|
which must be included in jbpm.hibernate.cfg.xml.
once i have created (but not signaled) a process instance i can schedule it like this:
| public void signalAsync(ProcessInstance processInstance, JbpmContext jbpmContext) {
| AsyncProcessSignalJob job = new AsyncProcessSignalJob(processInstance);
| jbpmContext.getJobSession().saveJob(job);
| }
|
|
does this look reasonable? have i overlooked something? i'm still in early testing
phase so i cannot guarantee that this code really runs stable.
any comments would be appreciated.
kind regards,
oliver
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237861#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...