Sunday, July 25, 2010

Glassfish ESB, easier than you think. Part I

Over the last 2 years I got to learn, use and enjoy OpenESB, we switched to GlassfishESB when it was released with the support of Sun. Unfortunately I am not using it anymore at work and I missed the 2.2 release in which there seems to have been a couple nice changes, but to get to the point. The concept of a ESB (Enterpise Service Bus) will seem daunting or intimidating to some people, this post is to get rid of that and show how developer friendly GlassfishESB can be. Another huge benefit people do not often mentioned is working on very large distributed applications a tool like GlassfishESB with it's visual representation of your entire deployment makes maintenance and system structural updates a lot simpler.

Anyways to begin...
Go download GlassfishESB / Netbeans / Glassfish and any other components you need here

Install it, start it up and you are probably half way done, it is that simple.

Ok so first thing you want to do is create a standard Java project.. and create some classes, for this demo I am just creating a simple "message" with a Header and Body:

Now the next bit is my way of "cheating" to actually have anything connect to the ESB process you need to have an webservice, you get that by defining a WSDL and XSD and adding them to the BPEL, but who wants to type out all that boring XML...

So now create an EJB Project:

Click next..

Click next... Finish

Add the Java project to the libs of the EJB project.

Create a new webservice...

And make sure that ... the EJBs' code looks like

Now for the cheat ...

This will generate the WSDL and XSD...

Now we create the BPEL Project

Copy the WSDL and XSD from the EJB Project..
Open the bpel... Drag the WSDL onto the little orange circle on the left, the following will popup:

Now your BPEL looks like:

Add a Receive, Assign and Reply to the BPEL, the edit the Receive:

Edit the Reply:

Click on the Assign and then on "mapper" in the bpel editor window, drag the contents of the In variable to the contents of the Out variable

Save, and done...

Now just add a composite application.

Open the Service Assmbly and drag the BPEL project onto the JBI module section:


Add some Endpoints from the Palette, connect the arrows:

Deploy.. and you are done.

If you like you can add a test to the Composite Application, very simple, On the Test folder, right click add, choose your main WSDL, choose the method you wanna test, it generates test xml based on the XSD. On the properties of the test set the port in ${HttpDefaultPort} in the properties of the test...and test...

In Part II , I will add some more EJBs, so that this actually becomes a functioning application and some more awesome GlassfishESB functionality.


  1. I also wanted to use glassfish, but it has big issues:

    1. It does not provide you process versioning.
    2. WorkFlow Management it XML based and does not provide a GUI to work on that.

    Untill these crucial features are provided, I do not think any BPM solution is complete.

  2. Hi,
    You are right it doesn't have those features, but don't you think that you should rather have a completely separate workflow system anyways?
    I personally wouldn't use a ESB as a workflow solution, more as a "controller" which interacts with the workflow engine. The functionality you are looking for (I read quickly on your blog) will be available within specialized workflow products not an ESB.


Popular Posts