<!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="https://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;">
    Using TaskService directly
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/tlucz">tlucz</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/772297#772297">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p>I've started using jBPM 5.3.0.Final. I want to use HumanTasks embedded in my application. So basing on thread:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="" href="https://community.jboss.org/thread/162963?start=15&amp;tstart=1">https://community.jboss.org/thread/162963?start=15&amp;tstart=1</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I created my own LocalHumanTaskHandler where in constructor TaskServiceSession is created:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskSession = taskService.createSession();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.session=session;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>ExecuteWorkItem method is taken from <span style="color: #445588; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-weight: bold; background-color: #ffffff;">GenericCommandBasedWSHumanTaskHandler</span>. The only change is to invoke:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>taskSession.addTask(task, content);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>instead of:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>client.addTask(task, content, new TaskAddedHandler(workItem.getId()));</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I can work with HT in a way e.g.:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>List&lt;TaskSummary&gt; taskList = wrapper.taskServiceSession.getTasksAssignedAsPotentialOwner("john", "en-UK");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>wrapper.taskServiceSession.taskOperation(Operation.Complete, lastTask.getId(), "john", null, null, null);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>It almost works correctly, task data is stored in DB but process instance is not updated after complete task. The problem is how can I register TaskEventHandlers. In <span style="color: #445588; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-weight: bold; background-color: #ffffff;">GenericCommandBasedWSHumanTaskHandler</span> there is a method:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="line" id="LC106" style="padding: 0 0 0 10px;"><span class="kd" style="font-weight: bold;">private</span> <span class="kt" style="color: #445588; font-weight: bold;">void</span> <span class="nf" style="color: #990000; font-weight: bold;">registerTaskEventHandlers</span><span class="o" style="font-weight: bold;">()</span> <span class="o" style="font-weight: bold;">{</span></p><p class="line" id="LC107" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">TaskEventKey</span> <span class="n">key</span> <span class="o" style="font-weight: bold;">=</span> <span class="k" style="font-weight: bold;">new</span> <span class="n">TaskEventKey</span><span class="o" style="font-weight: bold;">(</span><span class="n">TaskCompletedEvent</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">class</span><span class="o" style="font-weight: bold;">,</span> <span class="o" style="font-weight: bold;">-</span><span class="mi" style="color: #009999;">1</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC108" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">TaskCompletedHandler</span> <span class="n">eventResponseHandler</span> <span class="o" style="font-weight: bold;">=</span> <span class="k" style="font-weight: bold;">new</span> <span class="n">TaskCompletedHandler</span><span class="o" style="font-weight: bold;">();</span></p><p class="line" id="LC109" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">client</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">registerForEvent</span><span class="o" style="font-weight: bold;">(</span><span class="n">key</span><span class="o" style="font-weight: bold;">,</span> <span class="kc" style="font-weight: bold;">false</span><span class="o" style="font-weight: bold;">,</span> <span class="n">eventResponseHandler</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC110" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">key</span> <span class="o" style="font-weight: bold;">=</span> <span class="k" style="font-weight: bold;">new</span> <span class="n">TaskEventKey</span><span class="o" style="font-weight: bold;">(</span><span class="n">TaskFailedEvent</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">class</span><span class="o" style="font-weight: bold;">,</span> <span class="o" style="font-weight: bold;">-</span><span class="mi" style="color: #009999;">1</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC111" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">client</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">registerForEvent</span><span class="o" style="font-weight: bold;">(</span><span class="n">key</span><span class="o" style="font-weight: bold;">,</span> <span class="kc" style="font-weight: bold;">false</span><span class="o" style="font-weight: bold;">,</span> <span class="n">eventResponseHandler</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC112" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">key</span> <span class="o" style="font-weight: bold;">=</span> <span class="k" style="font-weight: bold;">new</span> <span class="n">TaskEventKey</span><span class="o" style="font-weight: bold;">(</span><span class="n">TaskSkippedEvent</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">class</span><span class="o" style="font-weight: bold;">,</span> <span class="o" style="font-weight: bold;">-</span><span class="mi" style="color: #009999;">1</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC113" style="padding: 0 0 0 10px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="n">client</span><span class="o" style="font-weight: bold;">.</span><span class="na" style="color: #008080;">registerForEvent</span><span class="o" style="font-weight: bold;">(</span><span class="n">key</span><span class="o" style="font-weight: bold;">,</span> <span class="kc" style="font-weight: bold;">false</span><span class="o" style="font-weight: bold;">,</span> <span class="n">eventResponseHandler</span><span class="o" style="font-weight: bold;">);</span></p><p class="line" id="LC114" style="padding: 0 0 0 10px;">&#160;&#160;&#160; <span class="o" style="font-weight: bold;">}</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>but I have no client so I have no possibility to register these events. Also TaskServiceSession object has no method to register ResponseHandlers. How can I resolve it?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I also read thread</p><p><a class="" href="https://community.jboss.org/thread/204619?tstart=270">https://community.jboss.org/thread/204619?tstart=270</a></p><p>but in this case I have no idea how to create TaskService which I need to pass to <span style="color: #445588; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-weight: bold; background-color: #ffffff;">LocalHTWorkItemHandler</span>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks in advance for any help.</p><p>kr,</p><p>Tadeusz</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/772297#772297">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://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>