Wednesday, December 3, 2008

10.1.3.4 on Jboss and Websphere

News
The Oracle SOA Suite 10.1.3.4 on Jboss AS 4.0.5 and WebSphere Application Server 6.1.0.15 have just released since the 25 of November.
Be carefull : the WAS version is now on 6.1.0.15 fixpack althought the JBoss version is still on 4.0.5.

From Metalink
I prefer give you the patch numbers since they are not easy to find ...
WebSphere patchset
SCRIPTS FOR SOA SUITE 10.1.3.4 PATCH FOR WEBSPHERE 6.1 #7566941

JBoss patchset
SOA SUITE 10.1.3.4 SCRIPTS FOR JBOSS 4.0.5 #7580739

The install guides are inside the patchset.

Enjoy.

Testing with Oracle BPEL - part 2

The writing of BPEL tests is done in JDeveloper, in a window which is similar to the BPEL process design. The tests are not coded with BPEL language and are not a standard as BPEL.

The testing language
The test design can be done by the designer or directly by writing XML tags, which is not really convenient, but there are some testing functionnalities not supported by the designer. That's why I will explain the main tags and attributes and their functions right now.

XMLtags & attributs Function/ Description
<BPELTest> Document root
<initiate @operation> Specify the behaviour of the test process instanciationreferencing a WSDL operation
<include> Include some other test (like a baseline)
<inboundMessage> Specify the incoming message
<emulate> Specify the activity is emulatedNotice : The <initiate> is always emulated
<activityDriver @activity> Do an action on an BPEL activity
<assertXML @variable,@part,@method> Assert the content of a XML variableaccording the method used (identical, similar)
<assertActivityExecuted @activity> Assert the number an activity is executed
<assertValue @var,@part,@method> Assert the content of a value variable (regexp, exactmatching)
<triggerOnMessage @onMessageName> Allow to emulate an incoming message on onMessageactivity (pick or onMessage)
<triggerOnAlarm @onAlarmName> Allow to emulate and trigger onAlarm activity

The above list is not complete, but it contains the main tags you will deal with.

Here is the hierachy in these tags :


If you want to have a overview of all the tags, you can consult the XML schema of the BPEL test language ($BPEL_HOME/bpel/system/xmllib/InstanceDriver.xsd)

With all this stuff, we'll able to do :
  • assert tests
    • XML variables asserts
    • values variables asserts
    • execution number asserts
  • emulation tests
    • incoming messages
    • invoke/receive/reply emulations (synchronous and asynchronous)
    • fault messages
    • on alarm triggers
Okay, next time, we'll do our first BPEL test.

Saturday, November 22, 2008

Testing with Oracle BPEL - part 1

One of the biggest challenge with the BPEL language is the unit testing.
How can I be sure that my tiny change in my BPEL process won't affect the global behaviour of my entire process ?

Test Driven Development
In test-driven development technique aka TDD, everything is based on tests. We create first the test, check if the new test fails when we run it, then write some code, and then check if the test succeed. In Java/J2EE, this technique is very powerfull and is used in extrem programming methodology.

Testing with Oracle BPEL
I recently find out Oracle BPEL provides a test framework (actually I knew it, but I never tried it because I wasn't very confident...).
This framework will enable us to use an approach very similar to TDD. In JDeveloper, we'll have our process design as usual and others windows with our tests design.

These next features are available :
  • emulate inbound and outbound messages (synch and asynch processes)
  • assert some values and XML data
  • assert the number of execution of an activity

With these functionnalities, we are now able to do :
  • lots of unit tests on our BPEL processes
  • integration tests

As in JUnit concept, all the tests can be unified in a test suite to run all tests together.
All the tests will be packaged with the BPEL suitcase.

Sunday, August 31, 2008

How to replay a scope in Oracle BPEL

An other useful tip is to know how to replay a scope from its begining.

There is an unknown bpel fault in Oracle which is the {http://schemas.oracle.com/bpel/extension}replay.
Generally, the http://schemas.oracle.com/bpel/extension namespace is called by the bpelx prefix. Then you can simply use the fault with :
<throw name="myReplayThrow" faultName="bpelx:replay"/>
You'll find the jdeveloper bpel process which shows how to use the replay fault here : ReplayFault.zip

The fault makes your current scope returns to its begining as you can see on this shot :



It can really helps the bpel design avoiding to have to much complexity in a process.
Be careful since the replay fault is a bpel fault as shown in its name ! Therefore, it will be catched by a catchall on the current scope

Note : You can also use this fault with the faults policy manager in the 10.1.3.3, but you don't have to implement the retry logic since this is implicit.

I know you are several to follow this blog, and I'd like to thank you for your support.
Talk you soon guys !

Thursday, August 21, 2008

Reference on the current bpel instance from a XPath function

How to get a reference on the current bpel process into a xpath function ?
That's a big question ...

This is very simple, but you have to know which properties you have to get from the xpathContext.

package com.bpelsoa.xpath;

import java.util.List;
import java.util.Map;

import com.collaxa.cube.engine.CubeContextHelper;
import com.collaxa.cube.engine.ICubeContext;
import com.collaxa.cube.engine.core.ICubeInstanceImpl;
import com.oracle.bpel.xml.xpath.IXPathContext;
import com.oracle.bpel.xml.xpath.IXPathFunction;
import com.oracle.bpel.xml.xpath.XPathFunctionException;

public class CubeInstanceXPath implements IXPathFunction {

  public Object call(IXPathContext context, List list)
      throws XPathFunctionException {

    Map xpathProperties = (Map) context.getVariableValue(null, null,"xpath-function-data");
    ICubeContext cubeContext = (ICubeContext) xpathProperties.get("ICubeContext");

    // get the cube instance from the cube context
    ICubeInstanceImpl cubeInstance = CubeContextHelper.getCubeInstance(cubeContext);

    // do something with cubeInstance ...
    
    return null;
  }
}

You can do any operations on the cubeInstance object (such as modify a partner link, set a correlation id, change any properties, ...) to modify your bpel instance.

Tuesday, August 5, 2008

Oracle BPEL 10.1.3.4 is out !

The new BPEL Process Manager from Oracle is finally out since the 30th of July !

This 10.1.3.4 version is a patchset which can be installed on a 10.1.3.1 (or more). That means you have to install the 10.1.3.1 version before, and then install the 10.1.3.4 patchset.
I regret this patchset wouldn't be a standalone installation... As usual, this is available only for OC4J applications servers (I know it should be available from September for IBM WebSphere).

Anyway, this new version is here, and I think Oracle BPEL is on a good way (good improvements, faster, usefull things).

The BPEL Console
This new version mainly focuses on the BPEL console by adding some gadgets as :
- improved statistics collection
- more visibility of the engine threading modele
- a XML validator to validation any requests before posting.

The BPEL Engine
- I find out and I think which is really good is the creation of a new asynchronous thread to feed the audit trail. In this case, if you start a new bpel process and if it crashes before the first dehydration point, you should be able to see the audit trail (how many times I tried some process which are impossible to debug since we do not have the audit trail .... !). I hope this point works.
- Embedded automatic recovery agent which can recover any messages or activities which would be in state failed (state unresolved or not handled by the dispatcher). This sounds very good because I get used to develop my own recovery scripts in order to recover this kind of unresolved messages ...
- JVM data collection as JVM thread dumps, JVM heap statistics

Misc
- Export of a process suitcase
- Deployement plan which is created in order to make easier the deployement on several environnements (developement, testing, production) which all have different hostnames and ports. It simply modify the URI of the import clause in the bpel descriptor file, XSD, WSDL ...

By the way, Jdeveloper 10.1.3.4 is also out ! (but it seems even more buggy than the 10.1.3.3, so take care to your bpel source code).

Talk you soon.

Wednesday, July 16, 2008

Custom XPath function in Oracle BPEL PM

Hi,

I'll present you today the way to do custom xpath function in Oracle BPEL Process Manager 10.1.3.x. This stuff is very usefull for basic things (as an isNumber() method, ID generator, ...) or more complex things (as XML operations, business stuff).

I did many projects with Oracle BPM 10, and I've got used to use lots of those functions.


Step 1 - Make a class which implements the IXPathFunction interface

The next class is a little tool which tests if a string is a number.
Class IsNumberFunction
:
package com.bpelsoa.xpath;

import java.util.List;

import org.w3c.dom.Node;

import com.collaxa.cube.xml.dom.DOMUtil;
import com.oracle.bpel.xml.xpath.IXPathContext;
import com.oracle.bpel.xml.xpath.IXPathFunction;
import com.oracle.bpel.xml.xpath.XPathFunctionException;

/**
* This implements a small tool which tests if a String is a Number.
*
* @author Raphaël
*
*/
public class IsNumberFunction implements IXPathFunction {

  /** Number of args for this XPathFunction. */
  private static final int NB_ARGS = 1;

  /** Index in the List of our argument. */
  private static final int INDEX_ARG = 0;

  /**
   * Is called by the BPEL engine.
   *
   * @see com.oracle.bpel.xml.xpath.IXPathFunction#call(com.oracle.bpel.xml.xpath
   * .IXPathContext, java.util.List)
   */
  @SuppressWarnings("unchecked")
  public Object call(IXPathContext context, List args)
      throws XPathFunctionException {

    // test if we have the right argument number
    if (args.size() != NB_ARGS) {
      throw new XPathFunctionException(
          "This function requires one argument.");
    }

    // extract the String of the argument from the BPEL process
    Object o = args.get(INDEX_ARG);
    String str = getValue(o);

    // call the business method
    return isNumber(str);
  }

  /**
   * Extract the value of our String.
   *
   * @param o object
   * @return a string which contains our value
   * @throws XPathFunctionException if error occurs
   */
  private String getValue(Object o) throws XPathFunctionException {
    if (o instanceof String) {
      return ((String) o);
    } else if (o instanceof Node) {
      return DOMUtil.getTextValue((Node) o);
    } else {
      throw new XPathFunctionException("Unknown argument type.");
    }
  }

  /**
   * Test if a String is a Number.
   *
   * @param str
   * the String to be tested
   * @return a boolean
   */
  private boolean isNumber(String str) {
    for (int i = 0; i < str.length(); i++) {
      if (!Character.isDigit(str.charAt(i))) {
        return Boolean.FALSE;
      }
    }
    return Boolean.TRUE;
  }
}

Step 2 - Register the xpath function to your BPEL domain
Edit the xpath-functions.xml file in the $BPEL_HOME/domains/bpelsoa/config directory.
Add these following lines into the bpel-xpath-functions tags.
<function id="isNumber">
  <classname>com.bpelsoa.xpath.IsNumberFunction</classname>
  <comment><![CDATA[This implements a small tool which tests if a String is a Number. The signature of this function is bpelsoa:isNumber(String || Node).]]></comment>
  <property id="namespace-uri">
    <value>http://bpelsoa.blogspot.com</value>
    <comment>Namespace URI for this function</comment>
  </property>
  <property id="namespace-prefix">
    <value>bpelsoa</value>
    <comment>Namespace prefix for this function</comment>
  </property>
</function>

Step 3 - Add your classfiles to the bpel classpath
Create a new directory in your domain home ($BPEL_HOME/domains/bpelsoa) called classes and add your classfiles into it or add your classfiles to your application directory (/product/your_app/classes). Don't forget to add the packages hierarchy.

Edit the shared library of your application server
  • OC4J : $ORACLE_HOME/j2ee/oc4j_soa/config/server.xml
-> locate the shared library called oracle.bpel.common
-> add a tag code-source with your classpath as the others code-source tags.
  • WebSphere 6.1 : In the administration console, go to shared library, select the oracleBPELServer scope, and edit the orabpel_sl lib
-> when editing the shared library, simply add your classpath with the others.


Step 4 - Using your new custom xpath function in a BPEL process
A custom xpath function can be used as any xpath functions. It has to be in an expression field from an assign activity (copy, append, insert after/before, etc.).
<assign name="xpathCall">
  <copy>
    <from expression="bpelsoa:isNumber('123')"/>
    <to variable="myBoolean"/>
  </copy>
</assign>


Enjoy your new xpath.

That's all.

Thursday, July 10, 2008

Apache ODE 1.2 with Oracle Database 10g

Hi there,

It can be very usefull to change the database for many reasons (your customer wants to have this brand, your customer has some commercial discounts, support, etc...).

I'll will show you how to use the RDMS Oracle Database 10g with Apache ODE 1.2 .war version.

You'll need the sysdba privileges in order to follow the next steps.
You can get the oracle.sql script in the directory apache-ode-war-1.2/sql.

Create an ODE tablespace
Connect to the sid :
sqlplus sys/manager@xe as sysdba

Then execute the SQL statement :
CREATE TABLESPACE ODE DATAFILE
'/ENTREPRISE/PRODUCT/ORACLEXE/ORADATA/XE/ODE.DBF' SIZE 1000M AUTOEXTEND OFF
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT MANUAL
FLASHBACK ON;

Feel free to adapt this to your environement (the dbf path, the autoextend property and the initial size of the tbs).


Create an ODE schema
Execute the SQL statement :
CREATE USER ode
IDENTIFIED BY ode
DEFAULT TABLESPACE ode
TEMPORARY TABLESPACE temp
PROFILE DEFAULT
ACCOUNT UNLOCK;
-- Roles
GRANT RESOURCE TO ode;
GRANT CONNECT TO ode;
ALTER USER ode DEFAULT ROLE ALL;
-- System Privileges
GRANT UNLIMITED TABLESPACE TO ode;
GRANT CREATE VIEW TO ode;
-- tablespace Quota
ALTER USER ode QUOTA UNLIMITED ON ode;

Populate the ODE schema
Load the Apache ODE 1.2 schema :
sqlplus ode/ode@xe @oracle.sql
Create the JDBC datasource
Add this in the Host tag to the $CATALINA_HOME/conf/server.xml file :
<Context path="/ode" docBase="ode" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/oracle/ode"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="ODE"
password="ODE"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:XE"/>
</Context>

Bind the ODE engine to the oracle datasource
Add the file $CATALINA_HOME/webapps/ode/WEB-INF/conf/ode-axis2.properties with this content :
ode-axis2.db.mode=EXTERNAL
ode-axis2.db.ext.dataSource=java:comp/env/jdbc/oracle/ode

Add the Oracle JDBC Driver to the tomcat lib directory
Add the file ojdbc14.jar (which you can find in the lib directory of your $ORACLE_HOME) to the $CATALINA_HOME/lib directory.

Ok we're done, that's all !
Just restart the tomcat and it should work.

Wednesday, July 9, 2008

Apache ODE 1.2 is released

Hi folks,

This is my first technical post, and what is better than to announce the Apache ODE 1.2 release ?

This new release sounds very good for several points :
  • Improvements for stability and performance
  • External variables: variables used in a process are not opaque to the outside world anymore. You can map them to a simple database table and manipulate them directly. This means assigning to a variable has the effect of inserting or updating a row in the database, while reading a variable, has the effect of selecting a row from the database (I'll do a post on this feature to test it)
  • Advanced endpoint configuration support : WS-Security & WS-RM
  • New SQL scripts packaged in the ditribution (Derby, MySQL, Oracle)
  • Lots of bugs fixed !
Talk you soon.
Raphaël.

Friday, June 27, 2008

Introduction

Hi,

This is a new blog which will be about all the SOA, BPM/BPEL, ESB concepts.

I'll try to explain different points as the best as I can in order to help you to fix all the potential issue which would occur.

Thanks a lot for reading this article.

Talk you soon.

Raphaël.