After working through the examples in this article, you should be able to do the following:
- Install NetBeans IDE and the GlassFish ESB
- Create a simple Business Process Execution Language (BPEL) 2.0 project
- Use the following BPEL nodes in designing a process: Process Start, Receive, Reply, Invoke, Assign, PartnerLink, Process End
- Use the Mapper feature of the Assign node
- Create a simple Composite Application Project
- Create a simple Composite Application Service Assembly (CASA)
- Create a Composite Application Test Case within NetBeans IDE
- Deploy a Composite Application (JBI and BPEL modules) to GlassFish ESB
Confession: I am a pragmatist. I do believe that SOA is more about the design—and not the technology. However, I also believe that if you don’t have some tools to implement some of the more complex design patterns for SOA, you are probably wasting a tremendous amount of time, energy, resources, opportunity, and money creating the infrastructure and plumbing that you will need anyway. SOA with tools is not evil. Misuse of tools, or worse, confusing the tool for SOA, is what needs to be avoided.
A recent client engagement has involved providing assistance in the design and implementation of a Service Oriented Architecture. The client’s core development expertise is primarily with Microsoft .NET technologies, while most of their legacy code runs on a mainframe.
Over the last few months, given the prospect of looming budget constraints, and the practical cost barriers that are encountered when scaling commercial SOA vendor products across the enterprise, I’ve spent quite a bit of time evaluating a number of different Open Source projects for possible consideration as part of the enterprise architecture technology stack.
I’ve been working with the GlassFish Java 5 EE Application Server for the last 18 months—using it primarily to run the Hudson continuous integration engine—and have been extremely pleased with its stability as well as the quality of the admin console.
As you can imagine, introducing Open Source tools into any organization can be quite challenging, but an unexpected ally arrived recently which has increased the attractiveness of that option: Budget Reductions.
In considering options for implementing an Enterprise Service Bus (ESB), my design principles favor a solution that will allow the creation of a “virtual bus”—without incurring a severe cost penalty for instantiating an instance of the necessary technology stacks on every server; as well as avoiding the hub-and-spoke enterprise architecture integration model.
Apache Synape looks promising—and is still under consideration, but the recent GlassFish ESB announcements have drawn my attention: On October 12, 2008, the GlassFish ESB V2 Release Candidate was made available. The General Availability (GA) Build was certified on December 5, 2008, and and Commercial Support for early adopters was made available as of December 23, 2008. A formal launch is planned for sometime in February 2009.
Just to be clear: I’m technology neutral. I always take into consideration an organization’s existing developer skillsets, the education commitment necessary to introduce new tools and technologies, the long-term maintenance and operational support issues, and the very real nature of limitations of available funding.
What Is GlassFish?
“GlassFish is a free, open source application server which implements the newest features in the Java EE 5 platform (the next version of the J2EE platform). The Java EE 5 platform includes the latest versions of technologies such as Enterprise JavaBeans (EJB) 3.0, JavaServer Faces (JSF) 1.2, Servlet 2.5, JavaServer Pages (JSP) 2.1, Java API for Web Services (JAX-WS) 2.0, Java Architecture for XML Binding (JAXB) 2.0, Java Persistence 1.0, Common Annotations 1.0, Streaming API for XML.”
What is GlassFish ESB?
GlassFish ESB v2 integrates the OpenESB project into the GlassFish Java 5 EE Application Server:
“Project OpenESB implements an Enterprise Service Bus (ESB) runtime using Java Business Integration (JBI) as the foundation, enabling the easy integration of web services to create loosely coupled, enterprise-class composite applications.“
The download of GlassFish ESB includes the following bundled components:
- NetBeans 6.1 + OpenESB addons
- GlassFish V2 UR2 Build 04 Release
- JBI Runtime Components: BPEL SE, JMS BC, HTTP BC, File BC, FTP BC, Database BC, LDAP BC, XSLT SE, Data mashup SE
- GlassFish Addons
- JBI Runtime
- JBI Design time Components (OpenESB NBM addons)
The following features are available in the basic installation and support modeling a wide variety of SOA design patterns:
|BPEL Design Palette includes:||CASA Design Palette includes:|
|Basic Activities:||Structured Activities:||WSDL Bindings:|
Other GlassFish Projects
Another GlassFish project that is beyond the scope of this article, but worth keeping an eye on, is GlassFish Server v3 Prelude:
“GlassFish v3 Prelude is the next major release of the GlassFish application server. GlassFish v3 Prelude provides a lightweight and extensible core based on OSGi, a web and scripting container, an easy-to-use Admin Console for configuration and management, and Update Center connectivity.“
Why Should You Care?
When you consider the cost of scaling an ESB across the enterprise, with many vendors adopting a per CPU pricing strategy, you can quickly find your costs spiraling into the millions of dollars (if you really want to plan for scalability). With budget constraints being a very real factor in how you plan the infrastructure and tooling to support an Enterprise Architecture/Service Oriented Architecture, the simple CPU cost burden of deploying a commercial vendor’s ESB strategy will drive many organizations to adopt a centralized ESB at worst, or a hub-and-spoke ESB model at best. The potentially optimum scalability strategy of implementing the ESB technology stack across all servers hosting services is quite often cost-prohibitive for many organizations to consider (using commercial ESB vendor products).
This is just one reason you might be interested in Open Source tools such as GlassFish ESB.
The vitality of the growth of the OpenESB Project code base is a second factor to consider:
Figure 1: OpenESB Source Code Line Count Growth
Reprinted with permission.
I’m not saying GlassFish ESB is the right tool for everyone…and indeed, its capabilities might not be a good fit for your requirements. What I am saying is that it is worth consideration as an option.
Now, it’s time to get started with a hands-on examination.
The GlassFish ESB installation is painless and straightforward. It comes bundled with the GlassFish, the Open ESB jars already integrated into the GlassFish installation, as well as the NetBeans IDE.
There are a number of different installation packages available for different platforms. At the time of this writing, the following were offered:
- Solaris/OpenSolaris SPARC
- Solaris/OpenSolaris X86
- Mac OSX X86
- Mac OSX PPC
Download GlassFish ESB
The first thing you’ll need to do is download the GlassFish ESB release that’s appropriate for your environment: https://open-esb.dev.java.net/Downloads.html.
At the time of this writing, Release Candidate 1 (Stable) was available. For this article, I downloaded the Windows version and installed it under Windows Vista.
Figure 2: GlassFish ESB Download File Name
Launch the installer executable
Figure 3: GlassFish ESB Installer Launched
Accept License Agreement
On the next screen, select the checkbox to accept the license agreement.
Install NetBeans IDE 6.1
I chose to accept the following defaults, based on where I have the Java JDK installed. You’ll simply need to specify where your JDK is installed.
Figure 4: GlassFish ESB Installation – Directory Options
Install GlassFish v2 ur2
You’ll want to verify that none of the following port assignments conflict with your existing applications.
Figure 5: GlassFish ESB Installation – Port Assignment Options
Figure 6: GlassFish ESB Installation – Review Summary
Click the Install button to proceed.
Setup should now be complete. You will be prompted with the option to register, which is recommended, so that you can stay informed of the latest news from Sun regarding future GlassFish ESB developments.
Now, wasn’t that easy?
Configuring GlassFish ESB
Launch NetBeans 6.1 IDE
Next, I’ll launch the NetBeans 6.1 IDE that was just installed.
In Windows, click Start > All Programs. Locate the entry shown in Figure 7 and click it to launch it.
Figure 7: Launch NetBeans 6.1 IDE
The NetBeans 6.1 IDE should now be running with the information shown in Figure 8 displayed:
Figure 8: NetBeans IDE Launched
Start GlassFish V2
The GlassFish ESB administration functions are integrated into the NetBeans 6.1 IDE. This greatly simplifies the developer’s workflow to design, code, and deploy applications.
- Click the “Services” tab.
- Click the “Servers” icon to expand it.
- Right-click GlassFish V2.
- Click “Start”.
- Confirm “startup complete” (see the lower portion of Figure 9).
Figure 9: Start GlassFish V2
A Quick Tour
Now that you have GlassFish ESB and NetBeans IDE installed, you’ll quickly touch on the NetBeans IDE user interface that enables you to administer GlassFish configuration and resources from within NetBeans.
Now, take a quick tour and see what is under the hood.
The nodes shown in Figure 10 should appear under GlassFish V2 in the NetBeans IDE “Services” tab:
Figure 10: GlassFish Nodes
Clicking the “Applications” node should display the following additional folders:
Figure 11: GlassFish Applications
Clicking the “Resources” node should display the following additional folders:
Figure 12: GlassFish Resources
To fit everything neatly into a single screenshot above, I didn’t expand the “Connectors” above, so here it is:
Figure 13: GlassFish Resources
Right-clicking the JVMs node will allow you to explore the various properties and options that are defined in the environment or can be configured through GlassFish ESB.
Figure 14: GlassFish JVMs Node
Figure 15: GlassFish JVM Options
Clicking the “JBI” node should display the following additional folders:
Figure 16: GlassFish JBI
Because this is an initial install, there are no entries yet under the “Service Assemblies” node.
Figure 17: GlassFish JBI Service Assemblies
Web Admin Console
Alternatively, you can manage GlassFish via the Web Admin Console by connecting to port 4848 [default]:
- Open a web browser: http://localhost:4848
- Default Admin logon: admin.
- Default Admin Password: adminadmin.
Figure 18: GlassFish Web Admin Console Logon
Note: If, after logging into the Web Admin Console, you happen to see a message indicating Restart Required, use the NetBeans IDE to perform the restart by right-clicking the GlassFish V2 node and selecting “Restart” (so you can avoid the need to open a command prompt and execute the batch scripts).
Figure 19: GlassFish Web Admin Console
Simple BPEL Example: Process Inbound Trouble Ticket
Note: The purpose of this article, and this first example, is to familiarize you with the process and tools, so it will be extremely simplified. This is not intended as an example of a real-life application.
In this example, you will create a simple BPEL 2.0 process and deploy it to the GlassFish ESB.
Your BPEL process flow for this simple demonstration will take an inbound Trouble Ticket SOAP Request and provide a simple SOAP reply message.
You will subsequently expose the BPEL process as a web service and invoke it using the CASA Test Case capabilities.
Create New BPEL Process
Click File > New Project.
Figure 20: NetBeans New Project Menu
Select the “SOA” project type, and “BPEL Module”.
Figure 21: NetBeans New BPEL Project
Specify the new BPEL project location
Project Name: CaptureTroubleTickets
You can accept the default project location, but in this example, I have modified the directory to simplify the path displayed onscreen.
Figure 22: NetBeans New BPEL Project Location
Click “Finish”. You should see the following in the “Projects” tab.
Figure 23: NetBeans New BPEL Project Created
Create BPEL Module from WSDL
A BPEL module interface is defined by a corresponding WSDL definition.
To simplify the steps needed to prepare for this example, a prebuilt WSDL file is available for you to download here: TroubleTicket.wsdl.
- In the Project folder view, right-click the Capture Trouble Tickets project folder.
- Select “New”.
- Select “Other”.
Figure 24: NetBeans > New > Other
- Select “XML” file type.
- Select “External WSDL Document(s).
- Click “Next”.
Figure 25: BPEL WSDL Import – Choose File Type
Specify resource location:
- Select “From Local File System”.
- Browse to where you saved the TroubleTicket.zip.
- Click “Finish”.
Figure 26: BPEL WSDL Import – Specify Resource Location
Your NetBeans IDE CaptureTroubleTickets project should reflect the successful import of the TroubleTicket.wsdl file under the “Process Files” folder.
Figure 27: BPEL WSDL Import – Success
Create the Trouble Ticket BPEL Process
In the CaptureTroubleTickets Project view:
- Right-click on the project folder.
- Click New > BPEL Process.
Figure 28: Create New BPEL Process
Note: The File Name property should be set to SubmitTroubleTicket. You will also note that “.bpel” suffix given to the Created File.
Figure 29: New BPEL Process – Name and Location
An empty BPEL Process is now defined within the project.
Next, you will customize the BPEL Process Flow.
BPEL Process Flow Design
The next few steps will demonstrate how to associate the WSDL that you just imported into the project as a new PartnerLink within the new BPEL process that you just created.
As you will note from the next screenshot, I have used arrows to help you locate the slightly shaded area in the NetBeans IDE which is known as the “Partner Lane” in a BPEL Design view.
Figure 30: Locate the “Partner Lane”
Create New Partner Link
To do this, you will drag-and-drop the TroubleTicket.wsdl file in the CaptureTroubleTicket project in the NetBeans IDE from the Project folder to what is known as the Partner Lane.
Note the difference between the screenshot in Figure 31, when the WSDL file is dragged into the “Partner Lane”—but the cursor is not yet hovering over the anchor…versus Figure 32.
Figure 31: Dragging WSDL to Partner Lane – Cursor Not Over Anchor
In this screenshot, the cursor is over the “Partner Lane” anchor.
Figure 32: Dragging WSDL to Partner Lane – Cursor Over Anchor
Now, drag-and-drop the TroubleTicket.wsdl file to the “Partner Lane” and release the cursor on top of the anchor.
When you release the cursor, you will be prompted with the Create New Partner Link screen (see Figure 33).
- Set the Name property to “PartnerLinkTroubleTicket”
- Keep the defaults for the rest of the properties:
- “Use a Newly Created Partner Link Type” is selected
- “Process will implement (My Role)” is selected
Figure 33: Create New Partner Link
You now should see the “Partner Link” icon in the “Partner Lane”.
Figure 34: New Partner Link Created
Add A BPEL Receive node
From the palette displayed in the right-hand corner of the NetBeans IDE, drag-and-drop a “Receive” node into the BPEL Process Flow.
Figure 35: Add Receive node
Click the “Edit Icon”.
- Set the “Name” property to “getTroubleTicket“
Figure 36: Receive node Property Editor
Click the “Create” button to define a new input variable.
Accept the default value by clicking “Ok”.
Figure 37: Create Receive Input Variable
As the red arrow below points out, the Receive node now maps back to the corresponding WSDL operation
Figure 38: Receive node Created
Add a BPEL Reply node
Next, you drag-and-drop a “Reply” node from the palette to a point just below the “Receive” node.
Figure 39: Add Reply node to BPEL Process
Modify “Reply” node properties…
- Right-click the new “Reply” node and click “Edit”.
- Set “Name: ” property to: “troubleTicketReply“.
- Select “PartnerLinkTroubleTicket” for the value of “Partner Link: “.
- Select “submitTroubeTicketOperation” for the value of “Operation: “.
- Select “Normal Response”
Figure 40: Modify Reply node Properties
Click “Create…” to create a Reply node Output Variable.
Figure 41: Create Reply node Output Variable
Accept the defaults provided and click “Ok”.
Click “Ok” to save the modifications to the Reply node’s properties.
You should now have a BPEL process that looks like the following:
Figure 42: BPEL Receive/Reply
So, what have you accomplished so far?
- Imported a WSDL.
- Created an empty BPEL process.
- Associated the imported WSDL with a Partner Link.
- Added a Receive node to the BPEL process.
- Associated the Receive node properties to the input WSDL operation.
- Added a Reply node to the BPEL process.
- Associated the Reply node properties to the output WSDL operation.
For now, you will simply stub out a response value to be returned in the Reply Message.
In the interest of brevity for this article, I’ve left out any interaction with a database or calling another Web Service. Covering all of the features available within the GlassFish ESB is beyond the scope of an article such as this. The intent of this article is to give you enough of an overview to whet your appetite to explore further on your own. There are suggested links provided at the end of this article if you want to explore further.
Map the BPEL Request to the BPEL Reply
Add the “Assign” node to the BPEL process:
- Drag an “Assign” node from the Basic Activities palette.
- Drop it in the available open node that is between the getTroubleTicket Receive node, and the replyTroubleTicket Reply node.
Figure 43: Add Assign node to BPEL Process
Select the new “Assign” node in the BPEL process and click the “Mapper” menu item
Figure 44: BPEL Assign Mapper
Select the “String Literal” from the “String” menu and drag it into the middle column.
Figure 45: Select Literal String for Mapper assignment
Enter a literal value of “TicketSubmitted“, and map the literal value to the part1 element of the SubmitTroubleTicketOperationOut message.
Figure 46: Map Literal String to Reply message.
You now have provided a stubbed out value for the SOAP Reply message to send back to the consumer of the service. A future iteration of this example could be extended to demonstrate accessing a database, invoking another service, or routing a message to a JMS Queue to store a Trouble Ticket as well as generating a unique Trouble Ticket Number to be returned in the SOAP Reply. However, the goal for this article is to simply provide a relatively high-level overview and introduction to the GlassFish ESB.
Save and Validate BPEL
By clicking the Source tab, your BPEL generated code should look like the following:
Figure 47: View BPEL Source
Build the Service Unit (JAR)
Right-click the CaptureTroubleTickets BPEL project root node and select the “Build” menu option (to build a jar file for the project)
Figure 48: Map Literal String to Reply message.
Within the context of a JBI container, the resulting jar is known as as a “Service Unit“—which is the smallest unit that can be deployed to a JBI container.
Create the Composite Application Service Assembly (CASA)
To deploy the Service Unit jar that was generated in the previous step, you will need to create a CASA project:
- Click File > New Project.
- Select “SOA” within Categories.
- Select “Composite Application” within Projects.
- Click “Next”.
Figure 49: Create New CASA Project
- Set Project Name to: TroubleTicketCASA
- Click “Finish”
Figure 50: Specify Name and Location for New CASA Project
You should now have a screen that looks like this:
Figure 51: Specify Name and Location for New CASA Project
Next, you add the JBI Module (the CaptureTroubleTickets project) to the CASA project.
- Drag-and-Drop the CaptureTroubleTickets root node (JBI Module) to the JBI Modules section of the TroubleTicketCASA Design view.
Figure 52: Add JBI project to the CASA project
Confirm that you have successfully added the JBI Module to the CASA project by checking your results with the screenshot in Figure 53.
Figure 53: JBI add to CASA completed
- Right-click the TroubleTicketCASA CASA project
- Select “Clean and Build”.
Figure 54: CASA project build success
Take a moment and Right-Click the troubleTicketPort in the WSDL Ports.
In particular, note the SOAP Address that is exposed, which can now be invoked by a consumer.
Figure 55: CASA SOAP Properties
Create CASA Test Case
In the Project explorer view, Under the TroubleTicketCASA project, right-click on the folder named “Test”.
Click “New Test Case”.
Figure 56: Create New Test Case
Accept the default Test Case Name, and then click “Next”.
Figure 57: New Test Case Name
Next, you select the WSDL for the Test Case, and then click “Next”.
Figure 58: Select WSDL for Test Case
Finally, you select the Operation from the WSDL for the Test Case, and then click “Finish”.
Figure 59: Select the Operation from the WSDL for Test Case
Enter the following values for the Test Case data:
- TroubleTicketDescription: Testing
- TroubleTicketSeverity: HIGH
- TroubleTicketApplication: Accounting
Click File > Save.
Figure 60: Enter Test Case Data
Deploying and Testing the Composite Application
You just have a few more steps to complete this demonstration:
- Make sure you have saved your work.
- Clean and Build the CaptureTroubleTickets project.
- Clean and Build the TroubleTicketCASA project.
- Deploy the TroubleTicketCASA project.
To deploy the CASA project, right-click the TroubleTicketCASA project icon in the Projects view, and click Deploy.
Figure 61: Deploy the CASA Project
Now, you are ready to test the Composite Application.
- Expand the TroubleTicketCASA project
- Expand the Test folder
- Right-click the TestCase1
- Click Run
- Confirm that the test SOAP output troubleTicketResponse contains a value of TicketSubmitted
Figure 62: Confirm Test Results
If you’ll check the console output window in NetBeans, you should see something like this, indicating a successful test:
Test TestCase1Concurrent.properties Passed. Threads count Success: <1> Error: <0> Not completed: <0>
This article has barely scratched the service of what is available within the GlassFish ESB and OpenESB projects. There simply are too many capabilities and features that are beyond the scope of an introductory article such as this. However, hopefully you are now intrigued enough to at least consider investigating GlassFish ESB further on your own.
There are significant developments underway in the GlassFish project community, and as your SOA/EA efforts may face tighter budget challenges, there is real value to be leveraged by considering the GlassFish Java EE Server and GlassFish ESB project as potential core components within your infrastructure. The excellent integration with NetBeans IDE simply adds to the value proposition.
There are some very interesting GlassFish adoption success stories that may help give you a better understanding of the level of serious consideration that has been given to including GlassFish ESB in some recent enterprise architecture efforts.
In researching GlassFish ESB for this article, I came across a number of resources that will help you get up-to-speed quickly, and increase your depth of knowledge of the capabilities of the GlassFish application server:
Web Resource Links
- GlassFish.dev.java.net: Home of the GlassFish projects (GlassFish, GlassFish ESB, GlassFish Prelude).
- wiki.GlassFish.java.net: GlassFish wiki page.
- GlassFish ESB User Documentation
- open-esb.dev.java.net: OpenESB project home
- wiki.open-esb.java.net: OpenESB wiki page
- OpenESB Component Catalog
- The Aquarium: The Sun blog for news from the GlassFish community – a great radiator of information.
- GlassFish Project – Tech Tips and Blogs
- GlassFish for Business: Important announcements from Sun regarding using GlassFish software in production.
- GlassFish Technology Partner Showcase
- Thomas Erl’s Community Site for SOA Design Patterns
Recommended Books for Further Reading
- Java. EE 5 Development using GlassFish Application Server
- Open-Source ESBs in Action
- Service-Oriented Java. Business Integration
- Building SOA-Based Composite Applications Using NetBeans IDE 6
- Beginning Database-Driven Application Development in Java. EE: Using GlassFish.
- SOA Using Java. Web Services
About the Author
Kelvin Meeks is the Founder of International Technology Ventures, Inc., a professional services consulting firm, based out of the Pacific Northwest, that specializes in providing clients with expertise in the design and implementation of high performance distributed Enterprise Architecture systems. Kelvin has worked in the Information Technology field for over 20 years in all phases of software design, development, testing, sales, and project management…from startups to Fortune 500 and Global 2000 firms.
Kelvin writes a technology research blog at intltechventures.blogspot.com