Version 2

    After providing a well defined set of Interfaces from the Human Task Module the next step is to expose those interfaces as services.

    Reference:

    https://community.jboss.org/wiki/HumanTaskModuleRoadMap

    https://community.jboss.org/wiki/HumanTaskAPIAndDataStructuresProposal

    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.

    The main focus of this experiments is to remove the need of handling any transport related code inside the Human Task Module.

    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.

     

    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.

     

    I've created a sample project showing how CDI services can be hooked up with Switchyard:

    https://github.com/Salaboy/human-task-poc-proposal/tree/master/human-task-switchard

     

    This project will show and demonstrate the following features:

     

     

    Introduction

    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.

    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.

    Exposing a Service via JMS

    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.

    From the project dependencies perspective we need to add the following dependencies to our pom.xml file:

            

    <dependency>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-api</artifactId>
                <version>0.5.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-plugin</artifactId>
                <version>0.5.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.switchyard.components</groupId>
                <artifactId>switchyard-component-camel</artifactId>
                <version>0.5.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.switchyard.components</groupId>
                <artifactId>switchyard-component-bean</artifactId>
                <version>0.5.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-test</artifactId>
                <version>0.5.0-SNAPSHOT</version>
            </dependency>
    

     

    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:

     

    https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/java/org/jboss/ht/services/TaskInstanceEndpoint.java

     

    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.

     

    We can see that the implementation of this interface is a simple facade which redirects the calls to our inject CDI service:

     

    https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/java/org/jboss/ht/services/TaskInstanceEndpointBean.java

     

    You can see the switchyard configuration file which exposes the service methods:

    https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-switchard/src/main/resources/META-INF/switchyard.xml

    Sync and Async services calls

    The following figure shows how both interactions should work.

     

    SyncAndAsyncInteractionsSwitchyard.png

     

     

    Creating Clients

     

    Schedule automatic interactions