<!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;">
    signal event doesn't work from REST API
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/rudi_fisher">Rudi Fisher</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/649256#649256">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I want to use REST API to call signal. There is some implementation in ProcessMgmtFacade of gwt-console-server for this. I see the source code and I finelly found this in CommandDelegate of jbpm-gwt-core:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">
public void signalExecution(String executionId, String signal) {
&#160;&#160; ksession.getProcessInstance(new Long(executionId)).signalEvent("signal", signal);
}
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This doesn't fulfil my requirements so I made changes to this class recompile and redeploy. This step is OK, because I made some other changes about this REST API (start process with params) and everythings work fins, so I think the problem is not in this my changed implementation of CommandDelegate. New implementation is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">
public void signalExecution(String executionId, String eventType, String eventValue) {
&#160;&#160; ksession.getProcessInstance(new Long(executionId)).signalEvent(eventType, eventValue);
}
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I took example of signal event from original examples to be sure that process is designed OK. I took BPMN2-EventBasedSplit.bpmn2. I tested in Eclipse and works fine - after signal call, process cointinued and finally finished. I deployed this process into my Guvnor repo and started by GWT console. Process stopped and waits at signal nodes (see attached picture).</p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/2-649256-17846/BPMN2-EventBasedSplit.bpmn2_signal_problem.jpg"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/2-649256-17846/450-83/BPMN2-EventBasedSplit.bpmn2_signal_problem.jpg </span></a></p><p>At this point I wanted to push process by send signal event by REST API with new implementation. Method signalExecution in CommandDelegate is called OK and this method take correct process instance (I have log line there to see process instance). But it seems signalEvent on process instance doesn't work. I'm using the same parameters for signal event in Eclipse and in CommandDelegate. I'm confused about what is different between execution in unit test in Eclipse and at server. I made many tests and examples but my probem has no solution to this day. I found some discussion about similar issues but this not solve this problem.</p><p>Working unit test in Eclipse</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">
public static final void main(String[] args) throws Exception {
&#160;&#160;&#160; // load up the knowledge base
&#160;&#160;&#160; KnowledgeBase kbase = readKnowledgeBase();
&#160;&#160;&#160; StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
&#160;&#160;&#160; ProcessInstance processInstance = ksession.startProcess("com.sample.test");
&#160;&#160;&#160; System.out.println("process instance:" + processInstance.getState());
&#160;&#160;&#160; ksession.signalEvent("Yes", "YesValue", processInstance.getId());
&#160;&#160;&#160; System.out.println("process instance:" + ksession.getProcessInstance(processInstance.getId()));
&#160;&#160;&#160; // NO
&#160;&#160;&#160; processInstance = ksession.startProcess("com.sample.test");
&#160;&#160;&#160; System.out.println("process instance:" + processInstance.getState());
&#160;&#160;&#160; //ksession = restoreSession(ksession, true);
&#160;&#160;&#160; ksession.signalEvent("No", "NoValue", processInstance.getId());
&#160;&#160;&#160; System.out.println("process instance:" + ksession.getProcessInstance(processInstance.getId()));
}

private static KnowledgeBase readKnowledgeBase() throws Exception {
&#160;&#160;&#160; KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
&#160;&#160;&#160; kbuilder.add(ResourceFactory.newClassPathResource("BPMN2-EventBasedSplit.bpmn2"), ResourceType.BPMN2);
&#160;&#160;&#160; return kbuilder.newKnowledgeBase();
}
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Not working code in CommandDelegate and calling at GWT server</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">
ksession.getProcessInstance(new Long(executionId)).signalEvent("Yes", "YesValue");
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For BPMN2-EventBasedSplit.bpmn2 see official examples in version 5.2.0 Final</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/649256#649256">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>