Wednesday, November 28, 2012

Article published | Fault Handling and Prevention (I)


Oracle Technology Network (OTN) published the article Fault Handling and Prevention - Part 1 (An Introduction to Fault Handling in a Service-Oriented Environment) by Ronald van Luttikhuizen and Guido Schmutz.

It is one thing to design and code the "happy flow" of your automated business processes and services. It is another thing to deal with unwanted, unexpected situations that might occur in your processes and services. The article, the first in a four-part series, will dive into fault handling and prevention in an environment based on Service-Oriented Architecture (SOA) and Business Process Management (BPM) principles. You will learn about the different types of faults that can occur and how fault handling in an SOA environment differs from fault handling in traditional systems. We will investigate what can go wrong in such environments based on a case study of an Order-to-Cash business process. For each of these problems you will learn about the out-of-the-box capabilities in Oracle Service Bus and Oracle SOA Suite that can be applied to prevent faults from happening and to deal with them when they do occur.

More resources



Stay tuned for parts II, III, and IV of the article! 


About the authors


Ronald van Luttikhuizen is Managing Partner and Architect with Vennster and an Oracle ACE Director
Guido Schmutz is Technology Manager for SOA and Emerging Trends with Trivadis and an Oracle ACE Director

Tuesday, November 27, 2012

BPEL and Fire-and-Forget Web Services

The other day I was discussing calling a Web Service from BPEL that does not return a result or returns a result that you don't care about: a Fire-and-Forget Web Service.
This is not a very common use case. Usually, you call a Web Service from BPEL and you use the result to determine what the next step will be, or you use the result to check that the call was successful. But that doesn't mean it never happens.

I decided to try two different use cases:
  1. Calling a Web Service that was generated with JAX WS annotations from a Java class that has a 'void' return type. 
  2. Calling a Web Service that was defined top down with a WSDL with no output message for the operation. 

Bottom up

The example is very simple, a Java class with JAX WS annotation with one operation:

package nl.vennster.demo.blog;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(name="HelloWorldService")
public class HelloWorld {
    
    @WebMethod
    public void helloWorld(String greeting){
        System.out.println("I do nothing with this " + greeting);
    }
}

The resulting WSDL snippet looks like this:
...
</types>
<message name="helloWorld">
  <part name="parameters" element="tns:helloWorld"/>
</message>
<message name="helloWorldResponse">
  <part name="parameters" element="tns:helloWorldResponse"/>
</message>
<portType name="HelloWorldService">
  <operation name="helloWorld">
    <input message="tns:helloWorld"/>
      <output message="tns:helloWorldResponse"/>
  </operation>
</portType>
<binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
  <operation name="helloWorld">
    <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
</operation>
</binding>
....

As you can see, an empty response is returned, if you call this Web Service with this request:

POST http://localhost:7101/Blog-HelloWorldService-context-root/HelloWorldServicePort HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
Host: localhost:7101
Content-Length: 212
X-HTTPAnalyzer-Rules: 1@localhost:8099

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://blog.demo.vennster.nl/">
   <env:Header/>
   <env:Body>
      <ns1:helloWorld>
         <arg0>Lonneke</arg0>
      </ns1:helloWorld>
   </env:Body>
</env:Envelope>

You get the following response:

HTTP/1.1 200 OK
Content-Type: text/xml;charset=UTF-8
X-Powered-By: Servlet/2.5 JSP/2.1
Date: Mon, 26 Nov 2012 20:55:04 GMT
X-ORACLE-DMS-ECID: 11d1def534ea1be0:-6225fc35:13b3e7a6f94:-8000-000000000000002a
Content-Length: 199
X-HTTPAnalyzer-RuleName: Pass through :

<?xml version = '1.0' encoding = 'UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:helloWorldResponse xmlns:ns2="http://blog.demo.vennster.nl/"/>
   </S:Body>
</S:Envelope>

Obviously, you don't care about this answer in your BPEL process: it is always the same and has nothing you can use.  However, if you invoke this service without defining the output variable BPEL will throw an error: 
Error(77): <invoke/> missing output variable specification


Top Down

Now let's see what happens if we define a WSDL with no output message:

...
    <message name="helloWorld">
        <part name="parameters" element="tns:helloWorld"/>
    </message>
    <portType name="HelloWorldService">
        <operation name="helloWorld">
            <input message="tns:helloWorld"/>
        </operation>
    </portType>
    <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="helloWorld">
            <soap:operation soapAction=""/>
            <input>
                <soap:body use="literal"/>
            </input>
        </operation>
    </binding>
    <service name="HelloWorldService">
        <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
            <soap:address location="http://localhost:7101/Blog-HelloWorldService-context-root/HelloWorldServicePort"/>
        </port>
    </service>
</definitions>

If you invoke this BPEL, there is no option to define an output variable, this field is disabled.



Conclusion

Fire-and-forget Web Services are supported in BPEL, but only if the WSDL is defined as such. If there is a response, then you have to create an output variable. Which you can then use, or ignore.




Saturday, November 24, 2012

Eventing Hello World

This week I presented the "Introduction in Eventing in Oracle SOA Suite 11g" session at the DOAG conference in Nürnberg. I used several demos in this session to show the eventing capabilities of SOA Suite. This blog contains the source code and accompanying explanation so you can replay the demo yourself.

Introduction
An event is the occurrence of something relevant, signals a change in state that might require an action. Examples of events are: an invoice that has been paid, a customer that moved to a new address, a new purchase order, and so on. Events are complimentary to processes and services: processes and services describe what should be done, events about when something important occurs. SOA is not only about (synchronous) services and processes (what); but also about events (when). Eventing improves decoupling in your SOA landscape.

Slides
The presentation slides can be viewed and downloaded from my SlideShare account. The presentation introduces the concept of eventing, discusses some basic eventing patterns, and talks about the implementation of eventing in SOA Suite using AQ, JMS, and EDN.




Code
You can download a zipfile containing the JDeveloper workspaces for the SOA Composites (DOAG2012_Eventing_SOASuite) and Java projects (DOAG2012_Eventing_Java) used in the demo here.

Prerequisites
You'll need an Oracle SOA Suite 11g runtime to deploy and run the SOA Composites. Oracle provides a pre-built SOA and BPM virtual machine for testing purposes that is easy to install.

Download JDeveloper 11g (11.1.1.6) or later from Oracle Technology Network to inspect and modify the SOA Composite and Java projects.

Setup
In order for the demos to run some plumbing needs to be done for AQ and JMS:

  • The configuration steps required for the AQ demos are listed in the aq_configuration.txt file that is part of the Queuing_Utilities JDeveloper project.
  • The configuration steps required for the JMS demos are listed in the jms_configuration.txt file that is part of the Queuing_Utilities JDeveloper project.
  • In JDeveloper modify the existing Database Connection to point to your DOAG12_JMSUSER database schema.
  • In JDeveloper modify the GenerateInvoice File Adapter of the Billing SOA Composite to write the invoice file to an existing directory of the SOA Suite runtime.
  • In JDeveloper modify the WriteSensorToFile File Adapter of the ProcessSensors SOA Composite to write sensor values to an existing directory of the SOA Suite runtime.
  • Use Enterprise Manager to create a partition in SOA Suite called doag2012_eventing.
  • Deploy the following SOA Composites to the doag2012_eventing partition of the SOA Suite runtime using JDeveloper, Enterprise Manager or scripts: Order2Cash, Dunning, Billing, and ProcessSensors.
  • Deploy the Java application CRM to the WebLogic Server.

Advanced Queuing (AQ)
The first demo shows the queuing capabilities of AQ and shows how to integrate SOA Composites with AQ queues:

  1. Insert a record in the ORDERS table in the DOAG12_WEBSHOP schema. 
  2. The BIT_ENQUEUE_NEW_ORDER_EVENT trigger will execute the ENQUEUE_NEW_ORDER_EVENT procedure that enqueues a message to the NEW_ORDER_QUEUE
  3. You should see a new event in the NEW_ORDER_QT queue table of the DOAG12_JMSUSER schema.
  4. If the Order2Cash SOA Composite is deployed you should see a new instance in Enterprise Manager. This process is started by receiving events from the NEW_ORDER_QT queue using an AQ Resource Adapter.

Java Message Service (JMS)
The next demo shows the publish/subscribe capabilities of JMS and shows how to integrate SOA Composites with JMS:

  1. Complete the Book Order Human Task of the Order2Cash process instance that was started in the previous step.
  2. The Order2Cash instance will use a JMS Adapter to publish an event to the JMS topic DOAG12_BillingTopic. You can inspect the topic in WebLogic Console and see that an event has been published. There are two subscribers to the JMS topic: the Billing SOA Composite (using a JMS Adapter) and the CRM Java application (using a Message-Driven Bean or MDB).
  3. In Enterprise Manager you should see a new instance of the Billing SOA Composite that is started through the JMS Adapter. The instance should have written an invoice file using the File Adapter.
  4. In the SOA Suite log file (e.g. user_projects/domains/[domain]/servers/[server]/logs) you should see a log statement produced by the CRM application that indicates that the event is received.

Event Delivery Network (EDN)
This demo shows the publish/subscribe capabilities of EDN and shows how to use EDN from SOA Composites:

  1. Wait for 5 minutes after the billing event has been published from the Order2Cash process instance using JMS. The OnAlarm branch will be activated and publish a DunningEvent using a Mediator component.
  2. The Dunning SOA Composite is subscribed to the DunningEvent, a new instance of this SOA Composite will be started and can be inspected from Enterprise Manager.
A second usage of EDN is demonstrated using the following steps:
  1. Start a new instance of the Order2Cash process by inserting a new order in the database. Complete the Human Task again. Only this time use Enterprise Manager to fire a PaymentEvent to EDN. This can be done by right-clicking the soa-infra node and selecting Business Events. Select the PaymentEvent and hit the Test button. You can use the PaymentExample.xml file from the Order2Cash JDeveloper project as example event payload. 
  2. Using correlation the running Order2Cash process instance will receive an in-flight event and will continue without starting the Dunning process.

Sensors and Composite Sensors
The last demo shows the sensor and composite sensor capabilities of SOA Suite. Composite sensors are used to add metadata to running instances so they are easier to find in Enterprise Manager or via the Java APIs of SOA Suite:
  1. Inspect the composite sensors of the Order2Cash SOA Composite in JDeveloper.
  2. In Enterprise Manager navigate to the instances of the Order2Cash SOA Composite. Use the Add Fields button to search for instances based on functional data such as customer name and order id. 
Alternatively, composite sensors can also be published using JMS.

Sensors and monitoring objects can be used to feed runtime data of BPEL component instances into Oracle BAM, or publish this data to JMS, Database, or AQ in a non-intrusive way. Sensors are based on configuration instead of adding additional activities and components to your SOA Composites:
  1. Inspect the sensor configuration of the Dunning BPEL component in JDeveloper. These sensors publish to the DOAG12_SensorQueue queue.
  2. In Enterprise Manager navigate to the instances of the ProcessSensors SOA Composite. You should see new instances that are started based on the published sensor events.

Conclusion
The presentation and the demos in this blog give you an overview of the eventing capabilities of SOA Suite. The demo is stuffed with different eventing techniques (AQ, JMS, EDN), this should not be considered a best-practice ;-) Analyze what the best eventing implementation is for your specific scenario.

Some best-practices:
  • Model events in your BPM and SOA projects;
  • Use events to notify running processes;
  • Expand the service registry to include events;
  • Use events for additional decoupling between processes and services;
  • Events is not just queuing, also consider publish/subscribe and event stream processing;
  • There is not a single best technology for eventing implementation in SOA Suite.

Friday, November 23, 2012

DOAG 2012

This week the German Oracle User Group, or DOAG as it is called in German, held their yearly conference. Like other years, the location was the conference center in Nuremberg, a beautiful city in the south.

Vennster was well represented in the SOA/BPM Space, we did the following sessions:
  • SOA Made Simple: service design (Ronald van Luttikhuizen)
  • SOA Made Simple: creating a roadmap for your SOA (Lonneke Dikmans) 
  • Effective Fault Handling in Oracle SOA Suite 11g (Ronald van Luttikhuizen)
  • Introduction in Eventing in SOA Suite 11g (Ronald van Luttikhuizen)
  • Using the B2B Adapter in a Dutch government project (Ronald van Luttikhuizen)
  • Securing heterogeneous systems using Oracle WebServices Manager (Ronald van Luttikhuizen and Jens Peters)
  • Deployment in Oracle SOA Suite and Oracle BPM Suite (Lonneke Dikmans)
  • Stop generating your User Interface! Start designing it (Lonneke Dikmans)
You can find the slides by Ronald and me on slideshare:
Of course there were also other presentations by other presenters ;) DOAG is a big conference, with over 400 presentations. Most of them cover cases, others explain the latest developments. There is a number of tracks that are of interest if you are working in the 'middleware space': BPM, Middleware & SOA, development, Java and Strategy and Business.  The English spoken sessions are not as popular as the German language sessions, but both are well visited. 

I visited three sessions, one case study titled "Dynamische Benutzer-Workflows mit SOA und BPM-Suite" by Arne Brüning, one about the new developments in EclipseLink called "The Evolution of Java Persistence" by Doug Clarke and the last one was a session titled "NoSQL and SQL: Blending the Best of Both Worlds" by Andrew Morgan. All three happened to be presented by Oracle. They were very different in nature. The workflow session discussed a customer case. It was interesting from that point of view. I would have preferred more technical depth, but the presenter was well prepared and had an interesting story to tell. The session by Doug about Eclipse gave a nice overview of the latest developments and put them into perspective of the history of TopLink and EclipseLink. I think that this is a good strategy: it shows that EclipseLink is both proven and modern: it has been around for years and part of the original team is still working there PLUS they have solutions for new developments like JSON, REST services, NoSQL and multi-tenancy. The final presentation was an example how not to do that. The presenter put NoSQL in the title in an attempt to attract a crowd. But the session was really about MySQL clusters. A lot of people left the session while he was talking, because it was completely off topic. The presentation itself was not bad, but the title was misleading.  

Unfortunately I did not have time to see more sessions, because of all the presentations we were doing ourselves. There certainly was a lot more I would have liked to listen to and I hope we will be back next year!