Esteban Aliverti [http://community.jboss.org/people/eaa] created the discussion

"Re: user task or script task ?"

To view the discussion, visit: http://community.jboss.org/message/625194#625194

--------------------------------------------------------------
Good questions, I will try to shed some light here:

First advise: DO NOT USE SCRIPT TASKS!  :)  Most of the times, during design 
time you already have the information if a particular task is going to be 
handled by a Human User or an external Service. Here, "external" can be: 
external of the process, i.e. a Java class, or external of the application, 
like a web-service or similar.
JBPM5 (and BPMN2) has 2 different ways to interact with Human and Services. 
User Tasks and Tasks (You also have Service Tasks, but I don't like them. You 
can do a research about them too if you want to  :) ). When you design your 
process, you need to choose one or the other.
In runtime, when you want to execute the process, you need to register a 
handler for each of the Tasks (whether Human or not) present in the process 
definition. When the execution reaches a Task node, the handler gets executed.
These handlers must implement:

org.drools.runtime.process.WorkItemHandler

and they must be registered before the process is executed using:

ksession.getWorkItemManager().registerWorkItemHandler("NAME_OF_WI_NODE", new 
MyParticularHandler());

In the case of Human Tasks, jBPM already comes with a default handler that you 
use for all the Human Tasks nodes of your process. The name of this handler is 
WSHumanTaskHandler. This handler will communicate with the Human Task Server 
implementation provided by jBPM5 and create a task there every time it is 
executed. The subclass WSHumanTaskHandler that you need to use will depend in 
the communication protocol you want to use between the handler and the Human 
Task Server (AFAIK, at the moment 2 protocols are supported: Mina and JMS).

In your particular situation where you want to run the same process and in some 
of the executions the Human Tasks nodes can be performed by Services and in 
some other real Users must take care of them, I would say that you can achieve 
this using different Handlers implementation for the Human Tasks Nodes. 
So, when the process needs to run with real Users, you can register the defautl 
Human Task Handler provided by jBPM5. When you want to mock these users using 
Services, you can provide you own handler that will get the parameters from the 
process, execute whatever logic they need and return what the original Human 
Task handler returned.  So, basically, you will be emulating a Human Task using 
a custom Handler.

Best Regards,
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/625194#625194]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to