<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: user task or script task ?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/eaa">Esteban Aliverti</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/625194#625194">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Good questions, I will try to shed some light here:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>First advise: DO NOT USE SCRIPT TASKS! <span> :) </span> 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.</p><p>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 <span> :) </span>). When you design your process, you need to choose one or the other.</p><p>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.</p><p>These handlers must implement:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'andale mono', times;">org.drools.runtime.process.WorkItemHandler</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and they must be registered before the process is executed using:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'andale mono', times;">ksession.getWorkItemManager().registerWorkItemHandler("NAME_OF_WI_NODE", new MyParticularHandler())</span>;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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 <span style="font-family: 'andale mono', times;">WSHumanTaskHandler. <span style="font-family: arial, helvetica, sans-serif;">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 <span style="font-family: 'andale mono', times;">WSHumanTaskHandler</span> 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).</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif;">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. </span></p><p><span style="font-family: arial, helvetica, sans-serif;">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.&#160; So, basically, you will be emulating a Human Task using a custom Handler.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif;">Best Regards,<br/></span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/625194#625194">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>