3 Replies Latest reply on Jan 8, 2009 9:33 AM by ebritt

    Struggling with ESB concept

    kw_richards

      Hi,

      Let me start by apologising for the long post, but I've been struggling for quite a while and
      just can't seem to do something which I see as trivial.

      Basicalliy I'm trying to expose a web service on the ESB that will execute some "actions",
      then invoke jBPM to do some "business actions" (NOT long running) and then execute some actions again.

      This must all happen in a request/reply manner synchronously.

      Below is a high level (example) depiction of what I'm trying to do.

       ---------------------
       | Web Service |
       ---------------------
       |
       ---------------------
       | Decrypt Message |
       ---------------------
       |
       ---------------------
       | Claims Check |
       ---------------------
       |
       ---------------------
       | Router |
       ---------------------
       (Quote) / \ (Apply)
       -------- --------
       | | | |
       ------------------- | | | | -------------------
       | Vaidate Message |------| | | |------| Vaidate Message |
       ------------------- | | | | -------------------
       | | | |
       ------------------- | | | | -------------------
       | Calcuate Price |------| jBPM | | jBPM |------| Check Stock |
       ------------------- | | | | -------------------
       | | | |
       ------------------- | | | | -------------------
       | Reserve stock |------| | | |------| Place order |
       ------------------- | | | | -------------------
       | | | |
       -------- --------
       | |
       -------------------- -------------------
       | Remove Claims | | Remove Claims |
       | Check | | Check |
       -------------------- -------------------
       | |
       -------------------- -------------------
       | Encrypt Response | | Copy to MIS |
       -------------------- -------------------
       | |
       -------------------- -------------------
       | Return Response | | Encrypt Message |
       | (Price) | -------------------
       -------------------- |
       -------------------
       | Return Response |
       | (Delivery Date) |
       -------------------
      



      If an exception occurs anywhere below the web service, I want to trigger the following activities.

       ---------------------
       | Remove Claims |
       | Check |
       ---------------------
       |
       ---------------------
       | Encrypt Message |
       ---------------------
       |
       ---------------------
       | Return Response |
       | (Incoming Message)|
       ---------------------
      


      The following shows an example jboss-esb.xml (in pseudo code) of what I'm trying to doe

      <services>
       <service
       category="Example"
       name="httpInterface"
       description="HTTP interface into service bus">
       <listeners>
       <jbr-listener name="Http-Gateway" busidref="exampleEntry_http" is-gateway="true"/>
       </listeners>
       <actions>
       <!-- The web service will route to the "Example:Start" service configured below using ServiceInvoker.deliverSync -->
       <action name="WS-EntryPoint" class="org.jboss.soa.esb.actions.soap.SOAPProcessor">
       <property name="jbossws-endpoint" value="Web Service"/>
       </action>
       </actions>
       </service>
      
       <service name="Start" description="Configure" category="Example">
       <actions mep="RequestResponse">
       <action name="Decrypt Message" class="..."/>
       <action name="Claims Check" class="..."/>
       <!-- action name="Configure fault EPR" class="..."/> -->
       <action name="Router" class="..."/>
       </actions>
       </service>
      
       <!-- Since the router can't route to actions, I created a "Service" for each "destination".
       I.e. One for quote and another for apply -->
       <service category="Example" name="Quote" description="Configure">
       <actions mep="RequestResponse">
       <action class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor" name="Quote">
       <property name="command" value="StartProcessInstanceCommand"/>
       <property name="process-definition-name" value="Quote"/>
       </action>
      
       <!-- Problem 1: This doesn't wait for jBPM to complete -->
       <action name="Remove claims check" class="..."/>
       <action name="Encrypt Response" class="..."/>
       <!-- Since it is request/response, the response message should now be returned -->
       </actions>
       </service>
      
       <!-- Since the router can't route to actions, I created a "Service" for each "destination".
       <service category="Example" name="Apply" description="Configure">
       <actions mep="RequestResponse">
       <action class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor" name="Apply">
       <property name="command" value="StartProcessInstanceCommand"/>
       <property name="process-definition-name" value="Apply"/>
       </action>
      
       <!-- Problem 1: This doesn't wait for jBPM to complete -->
       <action name="Remove claims check" class="..."/>
       <action name="Copy to MIS" class="..."/>
       <action name="Encrypt Response" class="..."/>
       <!-- Since it is request/response, the response message should now be returned -->
       </actions>
       </service>
      
       <!-- Problem 2: How do I trigger this service on an exception (E.g. Null Pointer) -->
       <service category="Example" name="Fault" description="Configure">
       <actions mep="RequestResponse">
       <action name="Remove claims check" class="..."/>
       <action name="Encrypt Response" class="..."/>
       <!-- Problem 3: How do I get the original incoming message -->
       <!-- Since it is request/response, the response message
       (which I want to be the original incoming message) should now be returned -->
       </actions>
       </service>
      


      The first problem (Problem 1) I encountered is that when invoking the BPMProcessor,
      it starts the process asynchronously and the next "action" gets invoked before the
      jBPM process completes.

      The next problem (Problem 2) is that I need to do some things whenever any kind of exception occurs.
      I don't know how to get the ESB to call my Example:Fault service. I've tried configuring a faultTo EPR
      in one of the actions in Example:Start, but then I can't get a reply back (the replyTo EPR gets lost).

      I've tried a number of things, but just can't seem to get it to do what I want.

      This is such a basic requirement that I'm struggling with that it leads me to think
      that either I'm misunderstanding basic ESB functionality, or that I'm completely
      misunderstanding JBoss ESB.

      So my first question is whether what I'm trying to do (depicted at the top) is suitable for an ESB
      and if so, how would I go about doing it. If someone can provide me even with a simple (pseudo) jboss-esb.xml
      as an example it would be greatly appreciated.

      Thanks

      Kevin

      PS. Anyone know the process of engaging Red Hat to consult in a commercial (paid) capacity around this problem?

      PPS. Things I've tried.

      Use the "exceptionMethod" in each action. The disadvantage is that the "exceptionMethod" does not
      get called accross services. I must thus have (for example) the "Remove Claims Check" as the first
      action on every service instead of only once on a fault.

      I've tried using mep="OneWay" with a service (ReturnResponse) that "routes" the response back to the client.
      When the other services are thus complete, they "route" to this (ReturnResponse) service.
      I still have the same problem as above on exceptions. When the "Example:Fault" is invoked on an exception,
      the replyTo EPR is lost and I thus can't route back to the caller.

      I have not yet found a way to execute jBPM synchronously, but currently I'm toying with the idea
      of writing a custom action that will invoke jBPM synchronously (using something like token.signal)