[jboss-user] [JBoss jBPM] - Re: Dynamic Fork + External Async WS invocation + problem

clandestino_bgd do-not-reply at jboss.com
Mon Feb 2 08:17:11 EST 2009


Hi, 1st, thanks for looking into this.
process looks like this: S-F-T-J-E
S: Start state, 
D: Dynamic Fork (based on WF variable creates N new tokens), 
T: Task Node (on create has Action Handler that calls WS), Task ends when WS make a callback, child tokens wait in 
J: Join.          
E: End state

- NPE in callback method:

  | JbpmTaskInstance taskInstance = (JbpmTaskInstance) context.getTaskInstance(taskInstanceId);
  | log.debug("documentId: " + taskInstance.getDocumentId());
  | 

context.getTaskInstance() returns null, nothing particulary intersesting in stacktrace, simply task instance with that ID cannot be found neither in context nor in DB in that moment.

My understanding of the subject, and please correct me if I am wrong is that in Dynamic Fork which looks like this:

  | for (int i = 0; i < numberOfDocuments; i++) {
  | String documentId = documentList.get(i);
  | // build a new token name
  | String tokenName = JPDLConstants.DOCUMENT_PREFIX+ documentId;
  | final Token newToken = new Token(rootToken, tokenName);
  | newToken.setTerminationImplicit(true);
  | context.getJbpmContext().getSession().save(newToken);
  | final ExecutionContext newExecutionContext = new ExecutionContext(newToken);
  | newExecutionContext.getJbpmContext().getSession().save(newToken);
  | node.leave(newExecutionContext);
  | }
  | 

after new ExecutionContext is constructed and node.leave(context) is called for Token #1, the task instance in that token is created, action handler is invoked and then the next token is processed in for loop, but task instance is still not persisted in DB physically.

What I would like to have is when I call this action handler and WS in it, to be able to save that task instance in DB, so callback method can find it immediately.

As far as I know, the default behavior is to propagate execution in ALL outgoing paths, until the wait state is reached in all of the child tokens and then to persist everything in DB.

Making task node async does not remove the problem. 
Again as far as I understand async continuations, you just spawn another thread but it does not commit stuff in DB. In other words, in both cases (regular or async task node). task instances will not be created in DB until all of them are not created, and that will happen when all child token paths are calculated while leaving Fork node.

Is this a nonsense? if yes, please help me understand.

Btw, It is completely clear that this problem is not related to WS, but to any async invocation. 

Thank you for any hint/idea/comment/question.
milan

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4206226#4206226

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4206226



More information about the jboss-user mailing list