<!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;">
    Human Task Module SwitchYard Integration
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="https://community.jboss.org/people/salaboy21">Mauricio Salatino</a> in <i>jBPM</i> - <a href="https://community.jboss.org/docs/DOC-18719">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>After providing a well defined set of Interfaces from the Human Task Module the next step is to expose those interfaces as services.</p><p>Reference: </p><p><a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-18617">https://community.jboss.org/wiki/HumanTaskModuleRoadMap</a></p><p><a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-18641">https://community.jboss.org/wiki/HumanTaskAPIAndDataStructuresProposal</a></p><p>Leveraging the power of CDI and its integration with frameworks like Switchyard, Camel and JMS I will be doing some experiments to integrate these technologies together.</p><p>The main focus of this experiments is to remove the need of handling any transport related code inside the Human Task Module. </p><p>Providing Sync and Async integration points will allow the Human Task Module to keeps it focus in the internal logic that it handles without adding complexity related with integration.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This integration need to allows us to integrate the module in SE as well as EE environments. HornetQ (JMS implementation) will be used to demonstrate this functionality. Quartz will be used to show the scheduling capabilities that can also be offered by SwitchYard.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've created a sample project showing how CDI services can be hooked up with Switchyard:</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/tree/master/human-task-switchard">https://github.com/Salaboy/human-task-poc-proposal/tree/master/human-task-switchard</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This project will show and demonstrate the following features:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><div class="toc" style="border: 1px dashed black; padding: 10px;"><ul><li>
<a class="jive-link-anchor-small" href="#Introduction">Introduction</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Exposing_a_Service_via_JMS">Exposing a Service via JMS</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Sync_and_Async_services_calls">Sync and Async services calls</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Creating_Clients">Creating Clients</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Schedule_automatic_interactions">Schedule automatic interactions</a>
</li>
</ul></div></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="Introduction">Introduction</h1><p>The human task module provides all the core logic required to manage human interactions. Using a set of services we will be able to create and interact with Human Tasks. </p><p>In order to make the integration from different application simplier a flexible mechanism for Async and Sync calls needs to be provided, without making the internal component logic a nightmare.</p><h1 id="Exposing_a_Service_via_JMS">Exposing a Service via JMS</h1><p>In order to expose our CDI service using Switchyard we will need to choose a transport and do the corresponding bindings. For this service we have chosen JMS and we will be using HornetQ as our JMS provider. </p><p>From the project dependencies perspective we need to add the following dependencies to our pom.xml file:</p><p class="line" id="LC48" style="padding: 0 0 0 10px;"><span class="nt" style="color: #000080;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;groupId&gt;</span>org.switchyard<span class="jive-xml-tag">&lt;/groupId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;artifactId&gt;</span>switchyard-api<span class="jive-xml-tag">&lt;/artifactId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;version&gt;</span>0.5.0-SNAPSHOT<span class="jive-xml-tag">&lt;/version&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;groupId&gt;</span>org.switchyard<span class="jive-xml-tag">&lt;/groupId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;artifactId&gt;</span>switchyard-plugin<span class="jive-xml-tag">&lt;/artifactId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;version&gt;</span>0.5.0-SNAPSHOT<span class="jive-xml-tag">&lt;/version&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;groupId&gt;</span>org.switchyard.components<span class="jive-xml-tag">&lt;/groupId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;artifactId&gt;</span>switchyard-component-camel<span class="jive-xml-tag">&lt;/artifactId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;version&gt;</span>0.5.0-SNAPSHOT<span class="jive-xml-tag">&lt;/version&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;groupId&gt;</span>org.switchyard.components<span class="jive-xml-tag">&lt;/groupId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;artifactId&gt;</span>switchyard-component-bean<span class="jive-xml-tag">&lt;/artifactId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;version&gt;</span>0.5.0-SNAPSHOT<span class="jive-xml-tag">&lt;/version&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;dependency&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;groupId&gt;</span>org.switchyard<span class="jive-xml-tag">&lt;/groupId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;artifactId&gt;</span>switchyard-test<span class="jive-xml-tag">&lt;/artifactId&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;version&gt;</span>0.5.0-SNAPSHOT<span class="jive-xml-tag">&lt;/version&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/dependency&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In order to expose our services, defined insid the human-task module (take a look at the other wiki page to find more about the CDI human task experiment) we need to create a service wrapper which will allows us to expose each method of our interfaces into a service method: </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/java/org/jboss/ht/services/TaskInstanceEndpoint.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/java/org/jboss/ht/services/TaskInstanceEndpoint.java</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Switchyard imposes some restrictions about the methods that can be exposed, and for that reason our services needs to be wrapped and the arguments to the services needs to be grouped. I've defined a simple POJO called TaskUserRequest to fulfill this requirement.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>We can see that the implementation of this interface is a simple facade which redirects the calls to our inject CDI service:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/java/org/jboss/ht/services/TaskInstanceEndpointBean.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/java/org/jboss/ht/services/TaskInstanceEndpointBean.java</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You can see the switchyard configuration file which exposes the service methods: </p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/resources/META-INF/switchyard.xml">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/resources/META-INF/switchyard.xml</a></p><h1></h1><h1 id="Sync_and_Async_services_calls">Sync and Async services calls</h1><p>The following figure shows how both interactions should work.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/18985/SyncAndAsyncInteractionsSwitchyard.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/18985/SyncAndAsyncInteractionsSwitchyard.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="Creating_Clients">Creating Clients</h1><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="Schedule_automatic_interactions">Schedule automatic interactions</h1></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="https://community.jboss.org/docs/DOC-18719">going to Community</a></p>

        <p style="margin: 0;">Create a new document in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>