Wednesday, December 19, 2012

SCA Composites: Java or BPEL?

Oracle SOA Suite offers different technologies to implement logic:
  • OSB to expose services and to create composite services
  • BPEL for process and orchestration logic and for composite services
  • Mediator to route and transform messages
  • BPMN for process logic
  • Human Task Service for human interaction
  • Business Rules for (reusable) business logic outside your components
  • Spring Context for programming logic in Java
In our project we were moving a composite service from OSB to BPEL because the code became too complex and too difficult to understand and maintain in the OSB flow. The service consisted of numerous calls to other services, loops, several transformations and relatively complex XPath expressions and a java call-out. 
I did not want to put a java call out in my BPEL process, I rather have the Java code as a first class citizen in my sca composite. This way it is clear that there is java code in the composite and it can be traced in the console. 

Moving the Java from OSB to the Spring context was very easy. 
  • First I removed all the static methods and refactored the Java class into a proper bean
  • Then I renamed the methods, so I did not have overloaded operations in the web service and ran the unit tests again
  • I created a Spring Context as described in the Oracle Documentation here
  • Finally I wired the BPEL component to the SCA context
  • I created assign and invoke activities in BPEL
  • I ran the deployment scripts that I created for SCA composites
This whole exercise took me about 10 minutes. Granted it was a very simple Java class. There are numerous advantages of Java code: I can test the Java class without deploying it. Refactoring of methods, variables etc support in the IDE (JDeveloper) makes changing the Java code very easy.

I need to move more BPEL logic into Java code. This will improve my productivity, increases the testability of the service and makes it much easier to read, compared to the combination of XSLT transformations with XPath and assign statements. I tweeted about this notion and Demed L'Her warned about the lack of runtime visibility of Java code.  

Java in SCA Spring context versus BPEL

Let's compare different requirements for both the implementation of the SCA component in Java or in BPEL:

Feature Java  BPEL Explanation
Productivity High Medium Refactoring is not supported in BPEL, if you want to change the name or namespace of the process, this is a lot of work. There is code completion for XPath in BPEL, this increases productivity considerably.
Maintainability High Medium XML code is hard to read, the visual designer hides the implementation of assigns and transformations. 
Testability High Low BPEL can only be tested after deployment, Java can be tested outside the container. 
Runtime visibility Low High BPEL has flow and audit trail, so you can see exactly what happened in your process
Recoverability Low High BPEL has a fault management framework that allows you to recover activities
Configurability High High Configuration plans and properties for both SCA Spring Context and BPEL
Calling services High High SCA offers easy access to services, no matter what the implementation of the component is, both Java and BPEL can easily call services

Unfortunately there is no single good answer for all your problems. It really depends on the service and the logic that you need. In other words, it depends on the requirements you have with regards to functionality, visibility and recoverability whether OSB, BPEL or Java in a Spring context is the best solution for your composite service. But the SCA context makes calling services and thus creating composite services in Java a lot easier than it used to be.

Of course, the evaluation of the requirements is subjective: I have been programming Java since 1997 and am very used to the testing and refactoring capabilities Java tools offer. People with a more declarative coding background might prefer BPEL for that reason. I am very interested in other peoples' experiences with these aspects.

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!



Wednesday, October 10, 2012

Compensation Hello World

There were several questions about compensation after the Effective Fault Handling in SOA Suite 11g session that Guido Schmutz and I presented at Oracle OpenWorld last week. The presentation included a live demo that showed how compensation can be used to undo previously executed actions in processes and services that are implemented in SOA Suite. Based on the questions, this blog explains the concepts of compensation, gives you an overview of the demo, and provides a download link to the JDeveloper demo project so you can play around with the demo yourself.

Concept

Process and service activities can be divided into unit-of-works, called transactions that are either executed (i.e. committed) as a whole or undone as a whole (i.e. rollbacked) due to some error or an explicit rollback command. When the activities within the same unit-of-work span multiple resources (databases, Java components, JMS topics, and so on) these resources all need to support global (XA) transactions and need to enlist in the global transaction, to support commits and rollbacks on the transaction as a whole.

It is not always possible to use transactions as a means to commit, or rollback related activities as a whole. For example when the invoked services do not support global transactions. Next to this, long running processes execute several (implicit) commits since transactions shouldn't be kept open too long: this degrades performance and causes completed activities to remain invisible to others. Once a commit has been executed, the committed activities cannot be rollbacked. Consider an Order-to-Process in which we book the customer's credit card in advance and deliver the ordered goods a few days later. The process will dehydrate at some point causing a commit on the active transaction. If delivery of the ordered goods fails we cannot rollback the credit card booking.

Compensation provides a mechanism to undo already committed activities by means of invoking opposite activities (i.e. compensation) in reverse order. For example booking the opposite amount of money to the credit card that was initially charged. SOA Suite provides the following activities to support compensation:

  • Compensation handler. Compensation handlers contain the activities that need to be executed as part of the compensation flow. These handlers are defined per scope, similar to catch blocks. Per scope you need decide if you need a compensation handler. 
  • Compensate activity. The activity that triggers compensation for a SOA Composite. Executing this activity will cause the invocation of compensation handlers for all successfully completed scopes that have defined a handler, and are not yet compensated. Only compensation handlers of scopes that are directly enclosed by the scope that contains the compensate activity will be executed. The handlers are executed in reverse order, so the handler of the last completed scope is executed first. 
Before we jump to the demo some considerations when using compensation:
  • Compensate activities can only be executed from catch blocks and compensation handlers.
  • Compensation activities either trigger compensation for all enclosed and completed scopes using the compensate activity (supported in BPEL 1.1 and 2.0), or can trigger compensation for one specific scope using the compensateScope activity (only BPEL 2.0).
  • Compensation handlers can only be defined on scope level, not on sequence level.

Demo

The demo consists of a SOA composite that implements a simplified Order-to-Cash process. The composite contains a single, asynchronous BPEL component called CompensationExample. After receiving the input message the process executes the following scopes and sequences:

  • Scope Register_Order. This scope simulates the registration of the new order using an Empty activity called Dummy_Register_Order. The scope defines a compensation handler that simulates an undo activity by updating the order with a new status (e.g. cancelled).
  • Scope Invoke_CreditCardService. This scope simulates the registration of the new order using an Empty activity called Dummy_Book_CreditCard. The scope defines a compensation handler that simulates an undo activity by charging the opposite amount to the credit card.
  • Sequence Throw_Fault. This sequence is added for demonstration purposes and throws a fault in case "compensate" is passed as input to the SOA composite; otherwise the process will complete normally. The fault is caught by the Catch_All sequence.
  • Sequence Catch_All. This sequence includes a Wait activity before triggering compensation using a Compensate activity. The wait enables you to inspect the process instance in Enterprise Manager before the compensation logic is executed. After the compensation is completed, the process will send a callback message to the client indicating a fault occurred for this process instance.

Process flow of the Compensation Hello World example

After the wait has finished the compensation handler of the Invoke_CreditCardService is executed. Finally, the compensation of the Register_Order scope is executed. Again, by including Wait activities you can inspect the sequence of events in Enterprise Manager.

The flow of events is shown in the following figures:


Process instance after fault is thrown, but before compensation is triggered
Process instance after compensation is triggered and the compensation handler for the Invoke_CreditCard_Scope is completed. The compensation handler for the  Register_Order scope is still active.
Process instance after all compensation handlers have been executed.
Process instance after compensation has finished and the callback message has been send to the client invoking the process.

Code

You can download the JDeveloper project for the Compensation Hello World example here.

Real-life

In real-life projects you wouldn't add Throw activities to your SOA composites to trigger compensation and test your compensation logic. In such cases you can best use the out-of-the-box SOA Suite Test Framework and BPEL Test Framework to simulate errors (e.g. unreachable services) in unit tests to inspect and test the compensation logic of your SOA composites.

Wednesday, October 3, 2012

Presentations at OpenWorld 2012


This blog contains a wrap up of our presentations at OpenWorld 2012.

Oracle Fusion Middleware Live Application Development (UGF10464)

In this three hour show moderated by Duncan Mills and Chris Muir, the audience could experience the dynamics between three different teams that are building an application based on Oracle Fusion Middleware:

  1. User Interface in ADF;
  2. Services in SOA Suite and Oracle Database; 
  3. Business processes in BPM Suite.

Behind the scenes at the presentation

It's the fourth time Vennster participated in the Live FMW Development sessions after appearances at ODTUG Kaleidoscope, UKOUG, and OBUG. For OpenWorld 2012 the team that prepared the application consisted of Lucas Jellema, Luc Bors, Aino Andriessen, Guido Schmutz, Lonneke Dikmans, and Ronald van Luttikhuizen. This time we tried a different approach in which we pre-built the application and focused on explaining and demoing it in the first part of the session. After that we made several changes and deployed the improved software components.




Some best-practices the team discussed:

  • Use Business Rules to allow for runtime modification of fast changing business logic instead of design time modifications and redeployment of services. Encapsulate useful Business Rules as separate services instead of adding them to existing SCA composites.
  • Include a heartbeat operation for every Web Service (e.g. by using the Mediator's Echo activity) so you can verify that all technical layers of the Web Service work without triggering a functional side effect. 
  • Invoke PL/SQL from DB Adapters instead of directly executing CRUD operations for additional decoupling.
  • Decouple components and introduce additional reliability and robustness by using events.

Effective fault handling in SOA Suite 11g (CON4832)

In this co-presentation with Guido Schmutz we explored how the out-of-the-box frameworks, patterns, and tools that are available in Oracle Service Bus and Oracle SOA Suite can help you to implement fault prevention and handling capabilities.

360 view during the Fault Handling presentation

The session was pretty well attended, and with an extended Q&A sessions at the end. I never had so many questions after a presentation; don't know if that's a compliment or not ;-) Some of the questions raised:

  • Wrapping asynchronous message exchanges as synchronous exchanges and vice versa. 
  • Where to execute long-running and statefull processes: SOA Suite rather than OSB.
  • Fault handling in fire-and-forget message exchanges: if there's no callback, implement fault handling in the service that is being called.
  • Can the Fault Management Framework of SOA Suite be used to catch internal BPEL faults: use catch activities for that purpose.
  • Transaction boundaries, dehydration points, and global transaction timeouts.
  • Compensation versus rollbacks.
  • Chaining exception policies using the Fault Management Framework.

The slides are available from Slideshare and answer some of these questions. A series of articles is underway that dives deeper into these subjects!


OpenWorld and JavaOne 2012 so far, and we're only halfway!

Not surprisingly the main focus of OpenWorld so far is Cloud and Cloud-related services and products. Oracle is further expanding its Cloud offerings in different areas by means of:

  • Offering IaaS (Infrastructure as as Service) next to PaaS and SaaS;
  • Presenting various of its Cloud products;
  • Announcing the Oracle Private Cloud for organizations that want infrastructure and data to be located on premise, while Oracle supplies and manages the infrastructure as a service. This is useful for organizations that have strict demands for location and control of sensitive data.

There's no escaping Oracle in San Francisco this week

Obviously this focus is not only seen in the big keynotes, but also felt in the various sessions at OpenWorld and JavaOne. For example with the announcement of the new "Pluggable" Oracle 12c Database that is engineered with multi-tenancy in mind. Another example is the excellent presentation that Doug Clarke gave at JavaOne today on the capabilities of EclipseLink. EclipseLink supports different multi-tenancy models: shared or dedicated applications integrating with shared or dedicated databases.

Bob Rhubart in the OTN lounge before the map showing OTN community member nationalities from all around the world

So how about Vennster's involvement in OpenWorld and JavaOne so far this year? Among others, we attended the ACE Director Briefing, participated in the Fusion Middleware Partner Advisory Council, hooked up with the SOA and BPM community, and will participate in an Oracle Technology Network vidcast by Bob Rhubart. We also presented several sessions of which you can read more in upcoming blogs.

Ronald interviewed at OpenWorld

Saturday, September 29, 2012

Email notifications from BPMN processes using the pre-built VM for SOA and BPM Suite 11g

In tomorrow's OpenWorld session UGF10464 - ADF EMG User Group: Oracle Fusion Middleware Live Application Development Demo a team of developers will build and demo an application based on Fusion Middleware (ADF, SOA Suite, BPM Suite, Database). We will use the pre-built Virtual Machine for SOA Suite and BPM Suite 11g for this. The VM contains a fully configured and ready-to-use SOA Suite and BPM Suite 11.1.1.6.0 installation (PS5). Note that this is a development VM that shouldn't be used for production environments.

The application implements the process of submitting, reviewing, and scheduling abstracts for a conference. An overview of its components is shown in the following figure:



Presenters will be notified of the progress of their abstract submission through email. For example after approving or rejecting the abstract and after evaluation of the presentation. This can be seen in the following figure that depicts the Abstract-to-Presentation process:



This blog explains how to configure the pre-built VM to send email notifications from BPMN processes.

Configure Email Server and Client

The VM is pre-installed with JAMES, an open-source Java mail server. JAMES is located in the following directory on the VM: /opt/ApacheJames/james-2.3.2. The mailserver is already prepopulated with several users. You can add your own users to it using Telnet (see http://james.apache.org/server/2.3.1/adding_users.html).


JAMES is preconfigured in the Virtual Machine to use emailExample.com as servername, meaning that any newly created email address will have the following format: username@emailExample.com; for example ronald@emailExample.com. You can change this setting in the following file: /opt/ApacheJames/james-2.3.2/apps/james/SAR-INF/config.xml.

Next you can use an email client to connect to JAMES to verify that emails can be send and received. JAMES is configured with the following port numbers: 110 for POP3 and 25 for SMTP.

If you connect to JAMES from outside the VM you have to make sure that port forwarding in VirtualBox is configured so that the SMTP and POP3 ports are accessible to your email client.


Configure BPM Suite

You can send emails from BPMN processes by using a Notification activity and choosing email as Notification Type in the implementation properties. Make sure the To address evaluates to an emailadress that exists in JAMES.


Next you have to configure BPM Suite in Enterprise Manager so that the notifications are sent through JAMES. You have to configure both the Email Driver Properties of the usermessagingdriver-email (part of the User Messaging Services or UMS), as well as the Workflow Notification Properties. This is described in a blog by Craig Barr.

Take care that you also configure the Workflow Notification Properties. Workflow Notification is primarily configured to enable email integration for Human Tasks. This way task assignees of new tasks are notified through emails and actionable tasks can be completed through emails. However, these settings also need to be configured to enable email notifications sent from processes.

Friday, September 28, 2012

Running EclipseLink DBWS 2.4.0 on GlassFish 3.1.2


In a previous blog I explained how to create a web service using the EclipseLink DBWS utility. This blog explains how to deploy this to GlassFish 3.1.2.

The main challenge is getting the right classes to load. But let's start from the beginning: create the war file.

Create the war file

First we create the war file with the DBWSBuilder utility. I defined a builder file on the employees table in the standard hr schema as follows:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<properties>
<property name="projectName">Employee</property>
<property name="driver">oracle.jdbc.OracleDriver</property>
<property name="password">hr</property>
<property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>
<property name="username">hr</property>
<property name="platformClassname">org.eclipse.persistence.platform.database.oracle.Oracle11Platform</property>
<property name="logLevel">all</property> 
</properties>
<table schemaPattern="%" tableNamePattern="EMPLOYEES"/>
</dbws-builder>

Second, I created the war file with the DBWS utility:
$ECLIPSELINK_HOME/utils/dbws/dbwsbuilder.sh -builderFile EmployeeTableBuilder.xml -stageDir . -packageAs glassfish employee.war

NB: don't forget to set the paths in setenv.sh in $ECLIPSELINK_HOME/utils/dbws/ directory.

Add libraries to the war file

The war file that is created assumes that the correct version of the  eclipselink.jar is on the classpath of the server.  So first we add two libraries to the WEB-INF directory:
  • eclipselink.jar
  • javax.persistence_2.0.4.v201112161009.jar
I would have liked it a lot better if I would have had the option in the DBWSBuilder utility to set a flag to include the eclipselink.jar and the persistence jar in the WEB-INF/lib directory, or to set a flag to tell it not to do that. Similar to the 'provided' property that Maven offers.
If you forget this step, there will be an exception in your $GLASSFISH_DOMAIN/logs/server.log file stating:

javax.enterprise.webservices.org.glassfish.webservices|_ThreadID=21;_ThreadName=Thread-2;|Deployment failed
java.lang.TypeNotPresentException: Type ProviderHelper not present

Add libraries to your domain

The JDBC driver needs to be added to the lib/ext directory of your glassfish domain. 

cp $ORACLE_HOME/jdbc/lib/ojdbc6.jar $GLASSFISH_DOMAIN/lib/ext

If you skip this step, or put the jar in the WEB-INF lib, you will get a SOAP Fault that is caused by a ClassNotFoundException:

com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class _dbws.DBWSProvider
....
...
Caused by: java.lang.NoClassDefFoundError: oracle/sql/TIMESTAMP
at org.eclipse.persistence.platform.database.oracle.Oracle9Platform.<clinit>(Oracle9Platform.java:109)

Test the service

Glassfish offers a tester for webservices. This does not work, because the container does not recognize the webservice. You get the following (incorrect) error:

Service {urn:EmployeeService}EmployeeService looks like a JAX-RPC based WebService.

Please note that the tester feature is supported for JAXWS based webservices only

Creating a project based on the deployed wsdl does work as expected.

Thursday, September 20, 2012

Fault Handling Slides and Q&A


AMIS organized its annual Oracle OpenWorld and JavaOne preview event last Tuesday. The event is organized for people that don't attend OpenWorld and for presenters to rehearse their sessions and get feedback from the audience. Vennster gave two presentations:

  • Using Eclipse DBWS to Interface with Legacy Applications - Lonneke Dikmans
  • Effective Fault Handling in Oracle Service Bus and SOA Suite 11g - Ronald van Luttikhuizen; co-presented at OpenWorld with Guido Schmutz, Technology manager at Trivadis

This blog includes the updated slides of the Fault Handling presentation and contains a Q&A section that answers questions from the audience at the preview event. Lonneke will post the slides of her presentation in a follow-up blog. Last but not least, thanks to AMIS for hosting the event!

Fault Handling 

It is one thing to architect, design, and code the “happy flow” of your automated business processes and services. It is another thing to deal with situations you do not want or expect to occur in your processes and services. This session dives into fault handling in Oracle Service Bus 11g and Oracle SOA Suite 11g, based on an order-to-cash business process. Faults can be divided into business faults, technical faults, programming errors, and faulty user input. Each type of fault needs a different approach to prevent them from occurring or to deal with them. For example, apply User Experience (UX) techniques to improve the quality of your application so that faulty user input can be prevented as much as possible. This session shows and demos what patterns and techniques can be used in Oracle Service Bus and Oracle SOA Suite to prevent and handle technical faults as well as business faults.


Q&A

This section lists answers to the questions that were raised during the preview event.

Q: Where can retries be configured in Oracle Service Bus?
The retry mechanism is used to prevent faults caused by temporary glitches such as short network interruptions. A faulted message is resend (retried) and might succeed this time since the glitch has passed. Retries are an out-of-the-box feature that can be used in Oracle Service Bus and Oracle SOA Suite using the Fault Policy framework. By default, retries are disabled in Oracle Service Bus.

In Oracle Service Bus retries can be configured for several artifacts, among others the following:

  • Retries can be configured on Business Services as part of their Transport Configuration. 
  • Retries can be configured for inbound JCA-based Proxy Services as endpoint properties: jca.retry.countjca.retry.intervaljca.retry.backoff, and jca.retry.maxInterval.
  • Retries can be configured for outbound JCA-based Business Services using the same endpoint properties.
  • Retries can be configured for JMS Proxy Services and (S)FTP Proxy Services as part of the Advanced Settings.
See Oracle's Developer’s Guide for Oracle Service Bus 11g for all possible retry configurations.

Mind transaction boundaries and write operations when configuring retries. For example, consider a flow that is composed of two actions in which the first action inserts a record in the database and then commits, while the second action invokes a Web Service. When the second action fails and the entire flow is retried, you might end up with two new, identical records.

Q: What other load-balancing algorithms can be used besides round-robin?
When there are multiple instances of a service that are invoked from Oracle Service Bus, load-balancing can be configured on Business Services. Load-balancing can prevent faults by retrying messages that were sent to unavailable endpoints to other, hopefully active endpoints. Load-balancing is disabled by default. When enabled, the default algorithm that is used for load-balancing is round-robin.

The Oracle's Developer’s Guide for Oracle Service Bus 11g lists all possible load-balancing algorithms:

"Specify the load balancing algorithm as any one of the following values:
  • Round-robin - This algorithm dynamically orders the URLs that you enter in the Endpoint URI field for this business service. If the first one fails, it tries the next one, and so on until the retry count is exhausted. For every new message, there is a new order of URLs.
  • Random - This algorithm randomly orders the list of URLs that you enter in the Endpoint URI field for this business service. If the first one fails, it tries the next one, and so on until the retry count is exhausted.
  • Random-weighted - This algorithm randomly orders the list of URLs that you enter in the Endpoint URI field for this business service, but some are retried more than others based on the value you enter in the Weight field.
  • None - This algorithm orders the list of URLs that you enter in the Endpoint URI field for this business service from top to bottom."
Q: How is throttling implemented in Oracle Service Bus (in-memory, JMS, etc.)? Are messages in the throttling queue lost when the server fails?
Throttling introduces a message queue between a Proxy Service and a Business Service that temporarily stores messages to prevent backend systems from overloading. Whenever the number of messages exceeds the thresholds as configured in the throttling settings, the message is stored in a queue. When the number of messages that need to be processed decreases, messages are removed from the queue and sent to the backend system via the Business Service.

The Oracle Administrator’s Guide for Oracle Service Bus 11g discusses throttling and its configuration:

"A throttling queue is an in-memory queue. Messages that are placed in this queue are not recoverable when a server fails or when you restart a server. When you delete or rename a business service, all the messages in the throttling queue are discarded."

Q: What values can be used as key for the Result Cache feature?
The result cache in Oracle Service Bus can be used to store data in-memory. When data is queried that is present in the cache, the data is fetched from memory instead of the query being sent to, and executed by the backend system. This decreases the load on the backend system. Note that this feature only works for data that is static; meaning the data is seldom changed. If not, the cache will result stale and out-of-date information. As part of the Result Cache feature you need to configure the key that is used to determine if the associated data is in the cache.

The Oracle's Developer’s Guide for Oracle Service Bus 11g says:

"Cache Token Expression – Oracle Service Bus uses a cache key to identify cached results for retrieval or population, and the cache token portion of the cache key provides the unique identifier. You can use an expression—the Cache Token Expression—to generate the cache token part of the cache key to uniquely identify a cached result for the business service.

The Cache Token Expression must resolve to a String or the value of simple content, such as an attribute or an element with no child elements. If the expression evaluates to null or causes an error, results are not cached."

Thursday, September 13, 2012

Managing EclipseLink using JMX


EclipseLink is an open-source persistency framework for mapping Java objects to relational data and vice versa which is called Object-Relational Mapping (ORM). Besides implementing the Java Persistence API (JPA) standard, it also provides capabilities for Object-XML Mapping (OXM) and the creation of Database Web Services.

The JPA standard specifies caching functionality. Caching improves performance since data that is already queried and present in the cache can be fetched from memory instead of executing all queries in the backend database. However, this means that data should also be modified through the same cache managed by the JPA provider. If not, the cache won't be aware of changes and becomes out-of-synch with the actual data stored in the backend. This results in incorrect data being returned to the clients of the EclipseLink-based application. A typical situation in which this occurs is when IT operations directly changes data in the database on behalf of users or when solving issues and thereby bypassing the cache.

There are a few approaches to deal with such situations:

  • Restart the application server or application after the change to clear the cache;
  • Disable caching in the application altogether;
  • Expand the application (user interface, persistency layer) so that IT operations has dedicated functionality to modify data through the application instead of being forced to modify data in the backend database;
  • Implement a mechanism to automatically invalidate the EclipseLink cache triggered by events from the database;
  • Configure the persistency layer so that entities in the cache are automatically invalidated on a regular interval making sure that data can only be incorrect or incomplete for a certain time-period.
The above approaches have drawbacks such as additional coding, negative impact on performance when caching is disabled, or increased downtime of the application.

This blog describes a way to manage EclipseLink caches that we use at customer projects to help IT operations and application managers and doesn't have the disadvantages named earlier. It uses:

  • the out-of-the-box support by EclipseLink for Java Management Extensions (JMX); 
  • the MBeans provided by WebLogic Server; 
  • the monitoring application JConsole that is JMX-compliant and shipped with the Java Development Kit (JDK). 
Using JConsole, EclipseLink caches can be monitored, managed, and invalidated at runtime without impact on running applications.

One-time configuration of WebLogic to enable remote JMX connections

Weblogic Server needs to be configured to allow for remote JMX connections that are set up from JConsole and to enable the invocation of MBeans. The following blogs show you how to accomplish this:


Some pointers here:

  • Make sure you add the Java options eclipselink.register.dev.mbean=true and eclipselink.register.run.mbean=true to the start script of the WebLogic Server on which the EclipseLink applications run. Adding these parameters makes sure that the EclipseLink MBeans show up in JConsole.
  • Restart the WebLogic Server after the configuration changes.

Using JConsole

After configuring and restarting WebLogic Server, the default WebLogic server logfile should include the endpoints for the JMX servers to which we connect using JConsole. For example:


<JMX Connector Server started at service:jmx:iiop://localhost:7001/jndi/weblogic.management.mbeanservers.runtime .> 
<JMX Connector Server started at service:jmx:iiop://localhost:7001/jndi/weblogic.management.mbeanservers.edit .> 
<JMX Connector Server started at service:jmx:iiop://localhost:7001/jndi/weblogic.management.mbeanservers.domainruntime .>


After setting the JAVA_HOME and WEBLOGIC_HOME environment variables as indicated in the blogs, you can now start JConsole using the command line:

jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\wljmxclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote -J-Dcom.sun.management.jmxremote


Enter the credentials you provided in WebLogic Server for the IIOP protocol and enter the JMX endpoint for the mbeanservers.runtime to connect to WebLogi Server. JConsole now lets you inspect and manage all sorts of aspects such as memory, threads, classes, and so on.

To view the currently active EclipseLink sessions click on the "MBeans" tab and expand the node "TopLink". Every active EclipseLink session is shown as separate subnode. Expand a session and select "Attributes" to inspect the EclipseLink session. Clicking on the "NumberOfObjectsInAllIdentityMaps" shows a graph displaying the number of cached entities.


You can now clear the cache of an EclipseLink session at runtime by executing the operation "invalidateAllIdentityMaps" on the "Operations" page. This operation can be used to clear the cache after someone, e.g. IT operations, modifies the backend data directly and bypasses the EclipseLink persistency layer.

Note (thanks to Shaun Smith): You should be calling invalidateAllIdentityMaps() which has replaced initializeAllIdentityMaps(). Invalidation ensures that object identity is not lost in a running transaction. Initialization does not and should only be used safely in single threaded dev/test.


By using this approach, IT operations and application managers can do their job that includes direct data modifications to solve urgent issues and user requests, and be able to refresh the EclipseLink cache without downtime and impact for end users.