<!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;">
    Trouble getting human task from task service
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/devilkazuya99">TC ONG</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/734663#734663">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 All,</p><p>I have a process that has multiple human tasks in it. I am using Human Task Service. I have problem getting the human task in 2 scenarios.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1&gt; Greb human task right after process start.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'andale mono', times;">...</span></p><p><span style="font-family: 'andale mono', times;">knowledgeSession.startProcess(process, processVariables);&#160;&#160;&#160; // start process</span></p><p><span style="font-family: 'andale mono', times;">...</span></p><p><span style="font-family: 'andale mono', times;">BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();</span></p><p><span style="font-family: 'andale mono', times;">taskClient.getTasksAssignedAsPotentialOwner(actor, "en-UK", taskSummaryHandler);</span></p><p><span style="font-family: 'andale mono', times;">int taskSize = taskSummaryHandler.getResults().size();</span></p><p><span style="font-family: 'andale mono', times;">logger.debug("Found " + taskSize + " task(s) from the Human Task Service.");</span></p><p><span style="font-family: 'andale mono', times;">...</span></p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p2"><span class="s4">It gives me 0 results.</span></p><p class="p2"><span class="s4">But if I go the database, the task was created.</span></p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p2"><span class="s4">Then I try Thread.sleep() for a while.<br/></span></p><p><span style="font-family: 'andale mono', times;">...</span></p><p class="p1"><span style="font-family: 'andale mono', times;">knowledgeSession<span class="s1">.startProcess(process, </span>processVariables<span class="s1">);&#160;&#160;&#160; // start process</span></span></p><p class="p1"><span style="font-family: 'andale mono', times;"><span class="s1">try</span> {</span></p><p class="p2"><span style="font-family: 'andale mono', times;"><span class="s3">&#160;&#160;&#160; logger</span><span class="s2">.debug(</span>"Wait for 2 sec."<span class="s2">);</span></span></p><p class="p1"><span style="font-family: 'andale mono', times;">&#160;&#160;&#160; Thread.sleep(2000);</span></p><p class="p1"><span style="font-family: 'andale mono', times;">} <span class="s1">catch</span> (InterruptedException e) {</span></p><p class="p1"><span style="font-family: 'andale mono', times;">&#160;&#160;&#160; e.printStackTrace();</span></p><p class="p1"><span style="font-family: 'andale mono', times;">}</span></p><p class="p1"><span style="font-family: 'andale mono', times;">...</span></p><p class="p1"><span style="font-family: 'andale mono', times;">BlockingTaskSummaryResponseHandler taskSummaryHandler = <span class="s1">new</span> BlockingTaskSummaryResponseHandler();</span></p><p class="p1"><span style="font-family: 'andale mono', times;">taskClient.getTasksAssignedAsPotentialOwner(<span class="s2">actor</span>, <span class="s3">"en-UK"</span>, taskSummaryHandler);</span></p><p class="p1"><span style="font-family: 'andale mono', times;"><span class="s1">int</span> taskSize = taskSummaryHandler.getResults().size();</span></p><p class="p2"><span style="font-family: 'andale mono', times;"><span class="s2">logger</span><span class="s4">.debug(</span>"Found "<span class="s4"> + taskSize + </span>" task(s) from the Human Task Service."<span class="s4">);</span></span></p><p class="p2"><span class="s4" style="font-family: 'andale mono', times;">...</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span class="s4">and this time I got the result. <br/></span></p><p class="p2">Can I say that when I look for the human task, it is not created in the task service yet.</p><p class="p2">Obviously what I am doing is stupid and there is a better way to implement it. </p><p class="p2">Can anyone enlighten me a little bit?</p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p2">2&gt; Second case is when I try to get the next task after completing one.</p><p class="p2"><span style="font-family: 'andale mono', times;">...</span></p><p class="p1"><span style="font-family: 'andale mono', times;">BlockingTaskOperationResponseHandler taskOperationHandler = <span class="s1">new</span> BlockingTaskOperationResponseHandler();</span></p><p class="p1"><span style="font-family: 'andale mono', times;">taskClient.complete(<span class="s1">task1</span>.getId(), <span class="s1">actor</span>, contentData, taskOperationHandler);</span></p><p class="p1"><span style="font-family: 'andale mono', times;">taskOperationHandler.waitTillDone(5000);</span></p><p class="p1"><span style="font-family: 'andale mono', times;">...</span></p><p class="p1"><span style="font-family: 'andale mono', times;">BlockingTaskSummaryResponseHandler taskSummaryHandler = <span class="s1">new</span> BlockingTaskSummaryResponseHandler();</span></p><p class="p1"><span style="font-family: 'andale mono', times;">taskClient.getTasksAssignedAsPotentialOwner(<span class="s2">actor</span>, <span class="s3">"en-UK"</span>, taskSummaryHandler);</span></p><p class="p1"><span style="font-family: 'andale mono', times;"><span class="s1">int</span> taskSize = taskSummaryHandler.getResults().size();</span></p><p class="p2"><span style="font-family: 'andale mono', times;"><span class="s2">logger</span><span class="s4">.debug(</span>"Found "<span class="s4"> + taskSize + </span>" task(s) from the Human Task Service."<span class="s4">);</span></span></p><p class="p2"><span class="s4" style="font-family: 'andale mono', times;">...</span></p><p><span class="s4"><br/></span></p><p class="p1" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p1">Again, anyone, someone, i need your great knowledge.. (ToT)</p><p class="p1"><span class="s1"><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="https://community.jboss.org/message/734663#734663">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>