JBoss ESB Journal Notes

Arya MirServers

May 15, 2012 (5 years and 3 months ago)

957 views

The core of JBossESB is Rosetta, an ESB that has been in commercial deployment at a mission critical site for over 3 years. JBossESB aims to provide a set of tools and a methodology that makes it simple to isolate business logic from transport and triggering mechanisms, to log business and processing events that flow through the framework, and to allow flexible plug-ins of ad hoc business logic and data transformations. Emphasis was placed on making it possible (and simple) for future users to replace/extend the standard base classes that come with the framework (and are used for the toolset), and to trigger their own “action classes” that can be unaware of transport and triggering mechanisms.






JBoss ESB
Journal Notes




http://www.tibco.com

Global Headquarters
3303 Hillview Avenue
Palo Alto, CA 94304
Tel: +1 650-846-1000

Toll Free: 1 800-420-8450
Fax: +1 650-846-1005
© 2009, TIBCO Software Inc. All rights
reserved. TIBCO, the TIBCO logo, The
Power of Now, and TIBCO Software are

trademarks or registered trademarks of
TIBCO Software Inc. in the United States
and/or other countries. All other product and
company names and marks mentioned in
this document are the property of their
respective owners and are mentioned for
identification purposes only.
Document
Table of Contents
Overview: ............................................................................................................ 3
1. JBOSS ESB AND JBOSS ESB SERVER SETUP .......................................... 5
1.1 JBOSS ESB................................................................................................................5
1.2 JBOSS ESB SERVER................................................................................................5
1.3 ANT Scripts ......................................................................................................5
2. SERVICE CREATION ...................................................................................... 5
2.1 StorePO Service ...................................................................................................5
2.2 GetDB Service............................................................................................................6
2.3 UpdatePO Service ................................................................................................7
2.4 GetPrice Service.........................................................................................................8
2.5 CompletePO Service..................................................................................................8
3. Screenshots.................................................................................................... 9
3.1 JBossESB server after deploying the purchase order StorePO service....................9
3.2 JBOSSWS Running Services...................................................................................11
3.3 Jboss-esb.xml...........................................................................................................11
4. Appendix ....................................................................................................... 12





















Document Title Here 2 Document
Overview:

The core of JBossESB is Rosetta, an ESB that has been in commercial deployment at a
mission critical site for over 3 years.

JBossESB aims to provide a set of tools and a methodology that makes it simple to
isolate business logic from transport and triggering mechanisms, to log business and
processing events that flow through the framework, and to allow flexible plug-ins of ad
hoc business logic and data transformations. Emphasis was placed on making it possible
(and simple) for future users to replace/extend the standard base classes that come with
the framework (and are used for the toolset), and to trigger their own “action classes” that
can be unaware of transport and triggering mechanisms.

Rosetta is built on four core architectural components:
• Message Listener and Message Filtering code. Message Listeners act as
“inbound” message routers that listen for messages (e.g. on a JMS Queue/Topic,
or on the file system) and present the message to a message processing pipeline
that filters the message and routes it (“outbound” router) to another message
endpoint.
• Data transformation via the SmooksAction action processor
• A content-based routing service
• A message repository, for saving messages/events exchanged within the ESB

These capabilities are offered through a set of business classes, adapters, and
processors, which will be described in detail later. Interactions between clients and
services are supported via a range of different approaches, including JMS, flat file
system, and email. A typical JBossESB deployment is shown below.

Document Title Here 3 Document



Getting Started: (12.7 hrs)

Installing the JBoss server takes very little time, but figuring out the right
version/components to use was very time consuming. The times recorded in the
following sections are after the exact version/components were identified.

JBossESB can be deployed on the standard JBoss application server or JBossESB
server and is bundled with the JBoss SOA Platform. However, figuring out the version
it works with required significant trial and error. One would expect it to work with the
latest version of the app server with no issues, but that was not our experience. We
asked questions on JBoss forums, but received no replies or very late replies.

JBossESB seems to work with the JBoss 4.2.2 application server. The JBossESB
server provides some configurations out of the box, making it a little quicker to get
started.

There is a package called JBoss SOA Enterprise Platform that seems to be a more
complete package, offers rapid installation, and provides configuration and bundling of
all necessary modules. It also seems to be more enterprise ready, as it includes
Document Title Here 4 Document
JBoss ON or JBoss Operations Network, which provides management and monitoring
functionality out of the box. But it is not open source and the trial license is available
for only 30 days.
1. JBOSS ESB AND JBOSS ESB SERVER SETUP


1.1 JBOSS ESB (3 mins)

I downloaded JBossESB 4.5 GA from jboss.org. It comes in .zip format, so I unzipped
the file and copied it to C drive. When I unzipped jbossesb-4.5.GA, the install
directory has a file called deployment.properties-example, which I had to rename as
deployment.properties. By default the file points to jbossesb-server-4.5.GA, so I did
not need to make any changes in this file. There was no easy tool to set these
deployment parameters in an error-proof manner.

1.2 JBOSS ESB SERVER (1 min)

I downloaded JBossESB Server 4.5 GA from jboss.org. I copied it to C drive. The
JBossESB was deployed on the JBossESB server. It takes one minute to configure
the server once you know how.

1.3 ANT Scripts (1 min)

I have apache-ant-1.7.1 in C drive. I had to create an ANT_HOME environment
variable pointing to C:\apache-ant-1.7.1. All deployment/configuration is based on
ANT. There is no easy-to-use UI provided with the JBossESB server.


2. SERVICE CREATION

2.1 StorePO Service 125 mins 13 sec

• This service inserts the purchase order information into the database.
• JBossESB supports a bottom-up approach to building a service, so I did not
make the schema for these services.
• Analysis took 25 minutes.
• To build this web service it is necessary to configure the following files:
Document Title Here 5 Document
a) build.xml
b) deployment.xml
c) jbm-queue-service.xml
d) jboss-esb.xml
e) web.xml
Configuration of the above files took 15 minutes.
• To develop the web service took 80 minutes.
• To compile classes took 5 seconds.
• To deploy the queues and service in the JBossESB server took 8 seconds.
• To test the service through the SOAP UI client and database took 5 minutes.

Reference: You can find the business logic for this service at:
PurchaseOrderWebServices\PurchaseOrder\war\src\org\jboss\soa\esb\PurchaseOrder\St
orePO.java

The time consuming part was the deployment descriptors and the coding of the business
logic, which in this case was fairly straightforward but there was code that needed to be
designed, tested, and deployed. Because there is no support for a top-down approach –
no support for working with the schemas and using them in the service WSDLs – it is time
consuming and limiting in terms of designing interfaces. There is no support for security,
so the security-related implementation needs to be embedded in the service
implementation. Functionality for logging and auditing, which is usually needed, will also
require implementation logic. If there is a need to use non-intrusive/asynchronous
logging, the logs will be sent to a JMS destination and it will be necessary to write code
for handling those log messages and either writing to a log file or a log table. This will
require explicit coding beyond the business logic.

With TIBCO, web services can be developed with a top-down approach that is less time
consuming – importing the schemas to generate the stub code based on the schemas. To
add a java component, you have to import abstract WSDL to the project and the design-
time wizard generates the stub code. JBossESB is geared toward implementation first,
which creates difficulty in deciding a service interface. The service design is not easy
because the business entity schemas are not the ones that drive the service interface; it
is the class design driving the service interface and the WSDL, leading to bad designs
and dependencies between business entities, schemas, services, and dependent
services.


2.2 GetDB Service 135 mins 13 sec

The usual non-business logic code is also needed in all services but is not necessarily
implemented in all the following services. The coding/testing was the most time
consuming part. Also, any changes in audits/logs require development changes,
redeployment, and testing.


Document Title Here 6 Document
• This service gets purchase order information and parts information into the
repository from the database.
• Analysis took 20 minutes.
• To build this web service it is necessary to configure the following files:
a) build.xml
b) deployment.xml
c) jbm-queue-service.xml
d) jboss-esb.xml
e) web.xml
Configuration of the above files took 15 minutes.
• To develop the web service took 95 minutes.
• To compile classes took 5 seconds.
• To deploy the queues and service in the JBossESB server took 8 seconds.
• To test this service through the SOAP client and database took 5 minutes.

Reference: You can find the business logic for this service at:
PurchaseOrderWebServices\GetDB\war\src\org\jboss\soa\esb\GetDB\GetDBService.java

2.3 UpdatePO Service 85 mins 13 sec

The coding, deployment, and testing is given in terms of the time compared to the TIBCO
suite. There are other aspects of the project where time is also consumed. For example, it
is a struggle to get any SOAP/JMS service to work. The samples are not much help and
there appears to be a bug that might require core ESB code changes. To expose
services, SOAP/JMS was dropped because of this issue and HTTP was used as an
option. JBoss forums did not provide much help on this.

• This service updates the status field in the Purchase Order table from pending to
approved. It also updates the quantity field in the parts repository table. This
service also invokes the GetPrice service through SOAP over HTTP.
• Analysis took 15 minutes.
• To build this web service it is necessary to configure the following files:
a) build.xml
b) deployment.xml
c) jbm-queue-service.xml
d) jboss-esb.xml
e) web.xml
Configuration of the above files took 15 minutes.
• To develop this web service took 50 minutes.
• To compile classes took 5 seconds.
• To deploy the queues and service in the JBossESB server 8 seconds.
• To test this service through the SOAP client and database took 5 minutes.

Document Title Here 7 Document
Reference: You can find the business logic for this service at:
PurchaseOrderWebServices\UpdatePO\war\src\org\jboss\soa\esb\UpdatePO\UpdatePO
Service.java

2.4 GetPrice Service 60 mins 13 sec

This is implemented with a Java-based adapter to call an SAP service. There are no
packaged application adapters provided with the product, which makes it very difficult and
time consuming as it practically requires us to develop a fully-functional adapter if
connection pools and interfacing mechanisms have to be implemented. For example, for
SAP there are BAPI, rfc interfaces provided by SAP and JCO libraries provided to
interface and call the interfaces supported by SAP. This requires extensive research for
each packaged application and good knowledge about the packaged applications
interfaces/APIs; the effort is equivalent to fully functional adapter development. The
numbers here are for a simulated service, including an attempt to build an SAP adapter
that could call a BAPI using the JCO APIs. The attempt is attached in the appendix, but it
is very rudimentary – nowhere close to a generic adapter as it supports only a specific
BAPI call. To make the adapter support all out-of-the-box BAPIs and custom BAPIs would
be a significant task and is estimated as a part of adapter development. Note that this
sample only supports BAPI and no rfc calls. Event publishing hooks from SAP to the ESB
layer is additional functionality that would need to be added to the adapter as it is
essential to event-driven SOA. The effort to create these hooks is also recorded in the
adapter section.

• This service invokes the SAP simulator service to get the current price of the
ordered parts and sends the current parts price information to CompletePO.
• Analysis took 10 minutes.
• To build this web service it is necessary to configure the following files:
a) build.xml
b) deployment.xml
c) jbm-queue-service.xml
d) jboss-esb.xml
e) web.xml
Configuration of the above files took 15 minutes.
• To develop this web service took 30 minutes.
• To compile classes took 5 seconds.
• To deploy the queues and service in the JBossESB server took 8 seconds.
• To test this service through the SOAP client and database took 5 minutes.

Reference: You can find the business logic for this service at:
PurchaseOrderWebServices\GetPrice\war\src\org\jboss\soa\esb\GetPrice\GetPriceServic
e.java


2.5 CompletePO Service 40 mins 13 sec
Document Title Here 8 Document

This service is similar in terms of the development effort and code that needs to be
written as discussed earlier for implementing logging/auditing/policy
management/security. However, it is implemented as a part of the service, which means
that any changes to the governance aspect would need additional time for development,
deployment, and further testing, adding to the complete lifecycle development time. This
extra coding effort is listed separately in the spreadsheet in the security section.

• This service updates the bill field and changes the status field to complete in
purchase order.
• Analysis took 5 minutes.
• To build this web service it is necessary to configure the following files:
a) build.xml
b) deployment.xml
c) jbm-queue-service.xml
d) jboss-esb.xml
e) web.xml
Configuration of the above files took 15 minutes.
• To develop this web service took 15 minutes.
• To compile classes took 5 seconds.
• To deploy the queues and service in the JBossESB server took 8 seconds.
• To test this service through the SOAP client and database took 5 minutes.

Reference: You can find the business logic for this service at:
PurchaseOrderWebServices\CompletePO\war\src\org\jboss\soa\esb\CompletePO\Compl
etePOService.java

3. Screenshots

3.1 JBossESB server after deploying the purchase order StorePO service

Document Title Here 9 Document



Description:
This screen shows the JBoss ESB server comments after deploying the StorePO service.
The last statement in the screenshot shows that WSDL published to the server and the
service is available.



Document Title Here 10 Document
3.2 JBOSSWS Running Services




Description:
This screenshot shows up-and-running services, which are deployed on the
JBossESB server.

By using this dashboard you can get the service concrete WSDLs. You can also
see the request count, response count, and fault count.

3.3 Jboss-esb.xml



Document Title Here 11 Document



Description:
This screenshot shows the Jboss-esb.xml file, which is used to define JMS
providers and actions.
4. Appendix

SOAP over JMS client code:

Description:
The following code sends a message to a queue.

Code:
// sending message to queue
// To persist the queue properties we need to create properties object
Properties properties1 = new Properties();

// setting properties to properties object one by one.
properties1.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.Na
mingContextFactory");

properties1.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interface
s");

properties1.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
Document Title Here 12 Document

//To initialize environment by passing properties
InitialContext iniCtx = new InitialContext(properties1);

// To look up ConnectionFactory in the environment
Object tmp = iniCtx.lookup("ConnectionFactory");

// QueueConnectionFactory is used for creating QueueConnection objects with
//point to point JMS provider.
QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;

// creating queue connection
conn = qcf.createQueueConnection();

//looking up queue
que = (Queue) iniCtx.lookup("queue/UpdatePO_gw");

// creating queue session
session = conn.createQueueSession(false,
QueueSession.AUTO_ACKNOWLEDGE);


// starting connection
conn.start();

// creating queue sender object to send a message to queue
QueueSender sen = session.createSender(que);

// creating a Object message. Message is wrapping a java object
ObjectMessage tm = session.createObjectMessage(orderId);

// Sending message to destination queue.
sen.send(tm);

// Closing sender.
sen.close();

// Stopping connection.
conn.stop();

// Closing session.
session.close();

// Closing connection.
conn.close();
}
Document Title Here 13 Document







SOAP over HTTP client code:

Description:
The following code sends a request message to a web service and gets a
response.

//setting service Url to variable
String SOAPUrl = "http://127.0.0.1:9080/GetPrice/GetPriceService";
String SOAPAction = "";

//Creating URL object by using SOAPUrl variable
URL url = new URL(SOAPUrl);

//Opening a connection
URLConnection connection = url.openConnection();

//Creating URL connection with HTTP specific features
HttpURLConnection httpConn = (HttpURLConnection) connection;




//DocumentBuilderFactory enables applications to obtain a parser that produces
DOM object trees from XML documents
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

//Creating DocumentBuilder object
DocumentBuilder db = dbf.newDocumentBuilder();

//Creating Document object to parse xml document.
Document doc = db.parse("GetPriceReq.xml");

//Getting node from document.
NodeList nl = doc.getElementsByTagName("arg0");

//Getting element.
Element ele = (Element)nl.item(0);

// Appending new text node with current orderId parameter.
Document Title Here 14 Document
ele.appendChild(doc.createTextNode(Integer.toString(orderId)));

// below statements used for converting xml document to xml string.
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);

String s3 = writer.toString();

// Getting bytes from the string
byte[] b = s3.getBytes();

httpConn.setRequestProperty( "Content-Length",
String.valueOf( b.length ) );

//Setting content type property to request.
httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");

//Setting SOAP action property to request
httpConn.setRequestProperty("SOAPAction",SOAPAction);

//Setting method to request
httpConn.setRequestMethod( "POST" );
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
// Creating OutputStream object to send request to web service.
OutputStream out = httpConn.getOutputStream();

//Sending request to web service
out.write( b );
out.close();

//Creating InputStreamReader object to get the response from web service.
InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());


BufferedReader in = new BufferedReader(isr);
String response = in.readLine();
System.out.println(response);
in.close();




Document Title Here 15 Document

SAP adapter code:


import java.io.*;
import com.sap.mw.jco.*;

public class NewClass {
public static void main(String args[])
{

int num = 100;
String id="" , name="" , branch ="" ,address1="" , address2="" , cell ="" ;

String NSID = "R"+num;

String studno = "1002"; // Input to be send to BAPI named as "ZSTUDFUN1"
IRepository repository; // The repository we will be using

try {
// Add a connection pool to the specified system
JCO.addClientPool( NSID , 100, "000", "BCUSER", "minisap", "EN",
"10.1.6.49", "00" );
// Alias for this pool , Max. number of connections , SAP client, userid
"
// password , language , host nameUnique , system number



repository = JCO.createRepository("MYRepository", NSID) ;
// Create a new repository
// Get a function template from the repository
IFunctionTemplate ftemplate =
repository.getFunctionTemplate("ZSTUDFUN1");
// Create a function from the template
JCO.Function function = new JCO.Function(ftemplate);
JCO.Client client = JCO.getClient(NSID); // Get a client from the pool
JCO.ParameterList input = function.getImportParameterList(); // Fill in
input parameters
input.setValue(studno,"ID");

client.execute(function); // Call the remote system
JCO.Structure ret =
function.getExportParameterList().getStructure("EXPORT");

System.out.println("Student Details");
// Get table containing the data
Document Title Here 16 Document
JCO.Table ittable = function.getTableParameterList().getTable("ITAB1");


for (int i = 0; i < ittable.getNumRows(); i++)
{
// Fetching data from SAP database and storing in local
variables
ittable.setRow(i);

id = ittable.getString("ID");
name = ittable.getString("NAME");
branch = ittable.getString("BRANCH") ;
address1 = ittable.getString("ADDR1") ;
address2 = ittable.getString("ADDR2") ;
cell = ittable.getString("CELL") ;
//Displaying the Data
System.out.println ("Student Number >"+id+"Student Name
>"+name+"Student Branch >"+branch+"Student Address1 "+address1+"Student
Address2 >"+address2+">Cell>"+cell );
}

}

catch (Exception e)
{
System.out.println (e);
}

Document Title Here 17