Task: Create Task ESB Services
Create Task ESB Services that are published as Web services for external consumption and may also be consumed as part of an orchestrated business process.
Disciplines: Service Development
Relationships
RolesPrimary Performer: Additional Performers:
InputsMandatory:
    Optional:
    • None
    Outputs
      Main Description

      Use the Service Model to identify the service name, task name, and request, response, and fault xsds.

      Task-specific services will typically have actions that specifiy some business logic that is performed in Java, a scripting language, Drools, or other. In these situations the XML will need to be transformed to POJOs before the business logic is executed. The execution of the business logic can be configured through an ESB Action. Actions exist for invoking Java classes, invoking EJBs, executing scripts, executing rules written in Drools, invoking Web services, etc. The following discussion assumes the use of a JMS service endpoint and business logic implemented with rules.

       A possible action chain might look like:

      SmooksAction (XML2POJO)

      BusinessRulesProcessor action (business logic)

      SmooksAction (POJO2XML)

       

      Steps
      Use the Eclipse File -> New JBoss ESB Project.
      Name the project the name of the service. E.g.DiscountService.
      Use the JBoss ESB editor to edit the jboss-esb.xml file.
      First add the providers to jboss-esb.xml.
      With ESB services deployed as web services there are no gateway providers required, instead only a single JMS provider is required for the ESB Service endpoint.
      Use the JBoss ESB Editor to create the service. Name it the same as the project, and name the Category TaskServices (or pick some other category naming convention).
      Create a listener and choose the jms-jca-provider as it is better performing.
      Use the source tab to add the XSD of the request message, response message, and fault message.
      Add a SmooksAction to map the XML to POJOs.
      Create a smooks-res.xml file to configure this transformation based on rules fact model and the task.
      For Drools-based task services, add a BusinessRulesProcessor action to perform the business logic.
      Add the name of the rule depl;oyment properties file for the specified rule (or the rulefile itself)
      Also add the names of the facts to be inserted into the rule engine working memory using the "object-paths" property.

      Example jboss-esb.xml element for a task service:

      <service category="TaskServices" 
               name="DiscountService" 
               description="Discount Task Service">
        <listeners>
          <jms-listener name="discount"
                        busidref="discountChannel"
                        maxThreads="1" />
        </listeners>
        <actions inXsd="/discountRequest.xsd"
                 outXsd="/discountResponse.xsd"
                 faultXsd="/discountFault.xsd">
          <action name="transformToPOJO"
                  class="org.jboss.soa.esb.smooks.SmooksAction">
            <property name="smooksConfig" value="/smooks-requues.xml" />
          </action>
          <action name="calculate discount"
                  class="org.jboss.soa.esb.actions.BusinessRulesProcessor" >
            <property name="ruleAgentProperties"
                      value="ruleAgent/discount-rules-deployment.properties" />
            <property name="object-paths">
              <object-path esb="Account" />
              <object-path esb="TollTransaction" />
            </property>
          </action>
        </actions>
      </service>

      Add another SmooksAction to transform POJOs back to XML
      Use FreemarkerTemplate approach
      Add another SmooksAction to transform POJOs back to XML
      Add another SmooksAction to transform POJOs back to XML
      Key Considerations
      Where action names are specified without spaces (e.g., SmooksTransformer), they are the names of out-of-the-box actions provided in the JBoss SOA Platform. Where the names have spaces (e.g., Hibernate Persistence action) they describe an action that must be provided to perform this functionality.
      More Information