Legal Notices
The information contained in this documentation is subject to change without notice.
JBoss Inc. makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. JBoss Inc. shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material.
Java™ and J2EE is a U.S. trademark of Sun Microsystems, Inc. Microsoft® and Windows NT® are registered trademarks of Microsoft Corporation. Oracle® is a registered U.S. trademark and Oracle9™, Oracle9 Server™ Oracle9 Enterprise Edition™ are trademarks of Oracle Corporation. Unix is used here as a generic term covering all versions of the UNIX® operating system. UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited.
Copyright
JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and individual contributors as indicated by the @authors tag. All rights reserved.
See the copyright.txt in the distribution for a full listing of individual contributors. This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the GNU General Public License, v. 2.0. This program is distributed in the hope that it will be useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. You should have received a copy of the GNU General Public License, v. 2.0 along with this distribution; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Software Version
JBoss ESB 4.4 GA
Restricted Rights Legend
Use, duplication, or disclosure is subject to restrictions as set forth in contract subdivision (c)(1)(ii) of the Rights in Technical Data and Computer Software clause 52.227-FAR14.
©
Copyright
Contents
Table of Contents
Contents iii
About
This Guide 5
What This Guide Contains 5
Audience 5
Prerequisites 5
Organization 5
Documentation Conventions 5
Additional Documentation 7
Contacting Us 7
What is the Registry? 9
Introduction 9
Why do I need it ? 9
How do I use it ? 9
Registry Vs Repository 10
SOA components 10
UDDI 11
The Registry and JBossESB 11
Configuring the Registry 12
Introduction 12
The components involved 13
The Registry Implementation Class 13
Using JAXR 14
Using Scout and jUDDI 14
Chapter 3 16
Registry Configuration Examples 16
Introduction 16
Embedded 16
RMI using the juddi.war or jbossesb.sar 17
RMI using your own JNDI Registration of the RMI Service 18
2.4 SOAP 20
UDDI Browser 23
Introduction 23
UB setup 23
Chapter 4 24
Registry Troubleshooting 24
Scout and jUDDI pitfalls 24
More Information 24
What is a Rule
Service? 25
Introduction 25
Rule Services using Drools 26
Introduction 26
Rule Set Creation 26
Rule Service Consumers 27
Configuration 28
Object Paths 32
Deployment and Packaging 32
What is
Content-Based
Routing? 34
Introduction 34
Simple example 34
Content Based Routing using Drools 36
Introduction 36
Three different routing action classes 36
org.jboss.soa.esb.actions.ContentBasedRouter 36
org.jboss.soa.esb.actions.ContentBasedWireTap 36
org.jboss.soa.esb.actions.MessageFilter. 37
Rule Set Creation 37
XPath Domain Specific Language 37
XPath and namespaces 38
Configuration 38
Object Paths 40
Stateful Rules 41
RuleAgent 41
RuleAgent and Business Rule Management System 42
Executing Business Rules 42
Changing RuleService implementations 42
Deployment and Packaging 42
Content Based Routing using Smooks 44
Introduction 44
Message Transformation 46
Overview 46
Smooks 46
Samples & Tutorials 46
XSL Transformations 48
jBPM Integration 49
Introduction 49
Integration Configuration 49
jBPM configuration 51
Creation and Deployment of a Process Definition 52
JBossESB to jBPM 53
Exception Handling JBossESB to jBPM 55
jBPM to JBossESB 55
EsbNotifier 55
EsbActionHandler 57
Exception Handling jBPM -> JBossESB 58
Scenario 1. Time-out 58
Scenario 2. Exception Transition 59
Scenario 3. Exception Decision 59
Service Orchestration 61
Introduction 61
Orchestrating Web Services 61
Orchestration Diagram 61
Process Deployment and Instantiation 66
Conclusion 68
The Message Store 69
Introduction 69
Message Store interface 69
Transactions 70
Configuring the Message Store 70
References 74
Index 75
About
This Guide
The Services Guide contains important information on changes to JBoss ESB 4.4 GA since the last release and information on any outstanding issues.
This guide is most relevant to engineers who are responsible for administering JBoss ESB 4.4 GA installations.
None.
This guide contains the following chapters:
Chapter 1, What is Content-Based Routing: An overview of why you would want to use CBR.
Chapter 2, Content-Based Routing: this chapter contains information on how to use the content based routing capabilities in JBossESB.
The following conventions are used in this guide:
|
Convention |
Description |
|
Italic |
In paragraph text, italic identifies the titles of documents that are being referenced. When used in conjunction with the Code text described below, italics identify a variable that should be replaced by the user with an actual value. |
|
Bold |
Emphasizes items of particular importance. |
|
Code |
Text that represents programming code. |
|
Function | Function |
A path to a function or dialog box within an interface. For example, “Select File | Open.” indicates that you should select the Open function from the File menu. |
|
( ) and | |
Parentheses enclose optional items in command syntax. The vertical bar separates syntax items in a list of choices. For example, any of the following three items can be entered in this syntax: persistPolicy (Never | OnTimer | OnUpdate | NoMoreOftenThan) |
|
A note highlights important supplemental information. A caution highlights procedures or information that is necessary to avoid damage to equipment, damage to software, loss of data, or invalid test results. |
Table 1 Formatting Conventions
In addition to this guide, the following guides are available in the JBoss ESB 4.4 GA documentation set:
JBoss ESB 4.4 GA Trailblazer Guide: Provides guidance for using the trailblazer example.
JBoss ESB 4.4 GA Getting Started Guide: Provides a quick start reference to configuring and using the ESB.
JBoss ESB 4.4 GA Programmers Guide: How to use JBossESB.
JBoss ESB 4.4 GA Release Notes: Information on the differences between this release and previous releases.
JBoss ESB 4.4 GA Administration Guide: How to manage the ESB.
Questions or comments about JBoss ESB 4.4 GA should be directed to our support team.
Chapter 1
What is the Registry?
In the context of SOA, a registry provides applications and businesses a central point to store information about their services. It is expected to provide the same level of information and the same breadth of services to its clients as that of a conventional market place. Ideally a registry should also facilitate the automated discovery and execution of e-commerce transactions and enabling a dynamic environment for business transactions. Therefore, a registry is more than an “e-business directory”. It is an inherent component of the SOA infrastructure.
It is not difficult to discover, manage and interface with business partners on a small scale, using manual or ad hoc techniques. However, this approach does not scale as the number of services, the frequency of interactions, the physical distributed nature of the environment, increases. A registry solution based on agreed upon standards provides a common way to publish and discover services. It offers a central place where you query whether a partner has a service that is compatible with in-house technologies or to find a list of companies that support shipping services on the other side of the globe.
Service registries are central to most service oriented architectures and at runtime act as a contact point to correlate service requests to concrete behaviors. A service registry has meta-data entries for all artifacts within the SOA that are used at both runtime and design time. Items inside a service registry may include service description artifacts (e.g., WSDL), Service Policy descriptions, various XML schema used by services, artifacts representing different versions of services, governance and security artifacts (e.g., certificates, audit trails), etc. During the design phase, business process designers may use the registry to link together calls to several services to create a workflow or business process.
The registry may be replicated or federated to improve performance and reliability. It need not be a single point of failure.
From a business analyst’s perspective, it is similar to an Internet search engine for business processes. From a developers perspective, they use the registry to publish services and query the registry to discover services matching various criteria.
A registry allows for the registration of services, discovery of metadata and classification of entities into predefined categories. Unlike a respository, it does not have the ability to store business process definitions or WSDL or any other documents that are required for trading agreements. A registry is essentially a catalogue of items, whereas a repository maintaines those items.
As the W3C puts it: An SOA is a specific type of distributed system in which the agents are "services" (http://www.w3.org/TR/2003/WD-ws-arch-20030808/#id2617708).
The key components of a Service Oriented Architecture are the messages that are exchanged, agents that act as service requesters and service providers, and shared transport mechanisms that allow the flow of messages. A description of a service that exists within an SOA is essentially just a description of the message exchange patter between itself and its users. Within an SOA there are thus three critical roles: requester, provider, and broker.
Service provider: allows access to services, creates a description of a service and publishes it to the service broker.
Service broker: hosts a registry of service descriptions. It is responsible for linking a requestor to a service provider.
Service requester: is responsible for discovering a service by searching through the service descriptions given by the service broker. A requestor is also responsible for binding to services provided by the service provider.

The Universal Description, Discovery and Integration registry is a directory service for Web Services. It enables service discovery through queries to the UDDI registry at design time or at run time. It also allows providers to publish descriptions of their services to the registry. The registry typically contains a URL that locates the WSDL document for the web services and contact information for the service provider. Within UDDI information is classified into the following categories.
White pages: contain general information such as the name, address and other contact information about the company providing the service.
Yellow pages: categorize businesses based on the industry their services cater to.
Green pages: provide information that will enable a client to bind to the service that is being provided.
The registry plays a central role within JBossESB. It is used to store endpoint references (EPRs) for the services deployed within the ESB. It may be updated dynamically when services first start-up, or statically by an external administrator.
As with all environments within which registries reside, it is not possible for the registry to determine the liveness of the entities its data represents, e.g., if an EPR is registered with the registry then there can be no guarantee that the EPR is valid (it may be malformed) or it may represent a services that is no longer active. At present JBossESB does not perform life-cycle monitoring of the services that are deployed within it. As such, if services fail or move elsewhere, their EPRs that may reside within the registry will remain until they are explicitly updated or removed by an administrator. Therefore, if you get warnings or errors related to EPRs obtained from the registry, you should consider removing any out-of-date items.
Chapter 2
Configuring the Registry
The JBossESB Registry architecture allows for many ways to configure the ESB to use either a Registry or Repository. By default we use a JAXR implementation (Scout) and a UDDI (jUDDI), in an embedded way.
The following properties can be used to configure the JBossESB Registry. In the jbossesb-properties.xml there is section called 'registry':
<properties name="registry"> <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/> <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/> <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/> <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/> <property name="org.jboss.soa.esb.registry.password" value="password"/> <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/> <!-- specify the interceptors, in order --> <property name="org.jboss.soa.esb.registry.interceptors" value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/> <!-- The following properties modify the cache interceptor behaviour --> <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/> <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/> </properties>
|
Property |
Description |
|
org.jboss.soa.esb.registry.implementationClass |
A class that implements the jbossesb Registry interface. We have provided one implementation (JAXRRegistry interface). |
|
org.jboss.soa.esb.registry.factoryClass |
The class name of the JAXR ConnectionFactory implementation. |
|
org.jboss.soa.esb.registry.queryManagerURI |
The URI used by JAXR to query. |
|
org.jboss.soa.esb.registry.lifeCycleManagerURI |
The URI used by JAXR to edit. |
|
org.jboss.soa.esb.registry.user |
The user used for edits. |
|
org.jboss.soa.esb.registry.password |
The password to go along with the user. |
|
org.jboss.soa.esb.scout.proxy.transportClass |
The name of the class used by scout to do the transport from scout to the UDDI. |
|
The list of interceptors that are applied to the configured registry. The codebase currently provides two interceptors, one for handling InVM registration and a second for applying a cache over the registry.
The default interceptor list consists solely of the InVM interceptor.
|
|
org.jboss.soa.esb.registry.cache.maxSize |
The maximum number of server entries allowed in the cache. If this value is exceeded then entries will be evicted on a LRU basis. The default value is 100 entries. |
|
org.jboss.soa.esb.registry.cache.validityPeriod |
The validity period of the caching interceptor. This is specified in milliseconds and defaults to 600000 (ten minutes). If this value is zero (or less) then there is no expiry specified on the cache. |

The registry can be configured in many ways. Figure 1 shows a blue print of all the registry components. From the top down we can see that the JBossESB funnels all interaction with the registry through the Registry Interface. By default it then calls into a JAXR implementation of this interface. The JAXR API needs an implementation, which by default is Scout. The Scout JAXR implementation calls into a jUDDI registry. However there are many other configuration options.
Figure 1. Blue print of the Registry component architecture.
Property: org.jboss.soa.esb.registry.implementationClass
By default we use the JAXR API. The JAXR API is a convenient API since it allows us to connect any kind of XML based registry or repository. However, if for example you want to use Systinet's Java API you can do that by writing your own SystinetRegistryImplentation class and referencing it in this property.
Propery: org.jboss.soa.esb.registry.factoryClass
If you decided to use JAXR then you will have to pick which JAXR implementation to use. This property is used to configure that class. By default we use Scout and therefore it is set to the scout factory 'org.apache.ws.scout.registry.ConnectionFactoryImpl'. The next step is to tell the JAXR implementation the location of the registry or repository for querying and updating, which is done by setting the org.jboss.soa.esb.registry.queryManagerURI, and org.jboss.soa.esb.registry.lifeCycleManagerURI respectively, along with the username (org.jboss.soa.esb.registry.user) and password (org.jboss.soa.esb.registry.password) for the UDDI.
Property: org.jboss.soa.esb.scout.proxy.transportClass
When using Scout and jUDDI there is an additional parameter that one can set. This is the transport class that should be used for communication between Scout and jUDDI. Thus far there are 4 implementations of this class which are based on SOAP, SAAJ, RMI and Local (embedded java). Note that when you change the transport, you will also have to change the query and lifecycle URIs. For example:
SOAP queryManagerURI http://localhost:8080/juddi/inquiry lifeCycleManagerURI http://localhost:8080/juddi/publish transportClass org.apache.ws.scout.transport.AxisTransport RMI queryManagerURI jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire lifeCycleManagerURI jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish transportClass org.apache.ws.scout.transport.RMITransport Local queryManagerURI org.apache.juddi.registry.local.InquiryService#inquire lifeCycleManagerURI org.apache.juddi.registry.local.PublishService#publish transportClass org.apache.ws.scout.transport.LocalTransport
For jUDDI we have two requirements that need to be fulfilled:
access to the jUDDI database. You will need to create a schema in your database, and add the jbossesb publisher. The product/install/jUDDI-registry directory contains db create scripts for you favorite database.
esb.juddi.xml. The configuration of jUDDI itself. If you do not use a datasource you need to take special care to set the following properties:
<entry key=”juddi.isUseDataSource”>false</entry> <entry key=”juddi.jdbcDriver”>com.mysql.jdbc.Driver</entry> <entry key=”juddi.jdbcUrl”>jdbc:mysql://localhost/juddi</entry> <entry key=”juddi.jdbcUsername”>juddi</entry> <entry key=”juddi.jdbcPassword”>juddi</entry>
if you do use a datasource you need something like
<entry key=”juddi.isUseDataSource”>true</entry>
<entry key=”juddi.dataSource”>java:comp/env/jdbc/juddiDB</entry>
The database can be automatically created if the user you have created has enough rights to create tables. Next make sure the isCreateDatabase flag is set to true, and that the sqlFiles parameter settings point to the database you are using. The jUDDI create scripts are located in the juddi.jar and jUDDI supports daffodildb, db2, derby, firebird, hsqldb, informix, jdatastore, mysql, oracle, postgresql, sybase (can be used for ms-sqlserver) and totalxml.
<!-- <entry key=”juddi.tablePrefix”>JUDDI_</entry> --> <entry key=”juddi.isCreateDatabase”>true</entry> <entry key=”juddi.databaseExistsSql”>select * from ${prefix}BUSINESS_ENTITY </entry> <entry key=”juddi.sqlFiles”> juddi-sql/mysql/create_database.sql, juddi sql/mysql/insert_publishers.sql </entry>
Chapter 3
Registry Configuration Examples
As mentioned before, by default the JBossESB is configured to use the JAXR API using Scout as its implementation and jUDDI as the registry. Here are some examples of how you can deploy this combo.
All ESB components (with components we really mean JVMs in this case) can embed the registry and they all can connect to the same database (or different once if that makes sense).

Figure 2. Embedded jUDDI.
Properties example:
<properties name="registry"> <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/> <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/> <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/> <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/> <property name="org.jboss.soa.esb.registry.password" value="password"/> <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/> </properties>
Deploy a version of the jUDDI that brings up an RMI service. The JBossESB comes with a juddi.war in the product/install/jUDDI-registry directory. This war brings up the regular webservices but also an RMI service. Along with the juddi.war you need to deploy a datasource which points to your jUDDI database. An example file is supplied for MySQL.
The jbossesb.sar also registers a RMI service. So you would only need to deploy the juddi.war if you need webservice access

Figure 3. RMI using the juddi.war
Properties example:
<properties name="registry"> <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/> <property name="org.jboss.soa.esb.registry.queryManagerURI" value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/> <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish"/> <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/> <property name="org.jboss.soa.esb.registry.password" value="password"/> <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.RMITransport"/> </properties>
The juddi.war is configured to bring up a RMI Service, which is triggered by the following setting in the web.xml
<!-- uncomment if you want to enable making calls in juddi with rmi --> <servlet> <servlet-name>RegisterServicesWithJNDI</servlet-name> <servlet-class>org.apache.juddi.registry.rmi.RegistrationService</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
Make sure to include, for example, the following JNDI settings in your juddi.properties:
# JNDI settings (used by RMITransport) java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1099 java.naming.factory.url.pkgs=org.jboss.naming
The RMI clients need to have the scout-client.jar in their classpath.
If you don't want to deploy the juddi.war you can setup one of the ESB components that runs in the the same JVM as jUDDI to register the RMI service. While the other applications need to be configured to use RMI.

Figure 4. RMI using your own JNDI registration
Properties example: For application 1 you need the Local settings:
<properties name="registry"> <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/> <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/> <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/> <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/> <property name="org.jboss.soa.esb.registry.password" value="password"/> <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/> </properties>
while for application2 you need the RMI settings:
<properties name="registry"> <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/> <property name="org.jboss.soa.esb.registry.queryManagerURI" value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/> <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish"/> <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/> <property name="org.jboss.soa.esb.registry.password" value="password"/> <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.RMITransport"/> </properties>
Where the hostname of the queryManagerURI and lifeCycleManagerURI need to point to the hostname on which jUDDI is running (which would be where application1 is running). Obviously application1 needs to have access to a naming service. To do the registration process you need to do something like:
//Getting the JNDI setting from the config String factoryInitial = Config.getStringProperty( Properties env = new Properties(); env.setProperty(RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_INITIAL,factoryInitial); env.setProperty(RegistryEngine.PROPNAME_JAVA_NAMING_PROVIDER_URL, providerURL); env.setProperty(RegistryEngine.PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS, factoryURLPkgs); InitialContext context = new InitialContext(env); Inquiry inquiry = new InquiryService(); log.info("Setting " + INQUIRY_SERVICE + ", " + inquiry.getClass().getName()); mInquery = inquiry; context.bind(INQUIRY_SERVICE, inquiry); Publish publish = new PublishService(); log.info("Setting " + PUBLISH_SERVICE + ", " + publish.getClass().getName()); mPublish = publish; context.bind(PUBLISH_SERVICE, publish);
Finally, you can make the communication between Scout and jUDDI SOAP based. Again you need to deploy the juddi.war and configure the datasource. You probably want to shutdown the RMI service by commenting out the RegisterServicesWithJNDI servlet in the web.xml.

Figure 5. SOAP.
Properties example:
<properties name="registry"> <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/> <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/> <property name="org.jboss.soa.esb.registry.queryManagerURI" value="http://localhost:8080/juddi/inquiry"/> <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="http://localhost:8080/juddi/publish"/> <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/> <property name="org.jboss.soa.esb.registry.password" value="password"/> <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.AxisTransport"/> </properties>
JBossAS 4.2 ships with older versions of Scout and jUDDI. It is recommended to remove the juddi.sar to prevent versioning issues.
Chapter 3
UDDI Browser
We are looking for a good web based console for jUDDI. In the meantime you can browse the jUDDI registry using the uddibrowser. The uddibrowser 'ub' can be downloaded from http://www.uddibrowser.org. Before configuring the ub make sure the juddi.war is deployed to the jbossesb.sar, to enable WS communication to jUDDI.
The ub is a standalone Java application. Start the ub and select Edit > UDDI Registries, and add an entry called jUDDI
Figure 6. Add a connection.
with settings
Figure 7. jUDDI connection settings
Click on 'connect' and select View > Find More > Find All Businesses
Figure 8. View all Businesses.
and in the left hand side you should see the Red Hat/JBossESB organization. You can navigate into the individual services and their ServiceBindings.
Figure 9. View Services and ServiceBindings.
Each ServiceBinding contains an EPR in its AccessPoint.
Some features of the uddibrowser may not work, but it should give enough functionality to maintain jUDDI. As mentioned before we are looking for a good web based console for jUDDI.
Chapter 4
Registry Troubleshooting
Make sure to put our version of the jaxr-api-1.0.jar, scout-0.7rc2-embedded.jar and the juddi-embedded.jar first. Other versions of these libraries are present in the JBossAS libraries and they are, for the time being, incompatible. This should get resolved in future release of the Application Server.
If you use RMI you need the juddi-client.jar.
Make sure the jbossesb-properties.xml file is on the classpath and read or else the registry will try to instantiate classes with the name of 'null'.
Make sure you have a juddi.properties file on your classpath for jUDDI to configure itself. JBossESB uses esb.juddi.xml, but generates the juddi.properties file for jUDDI to read.
Make sure to read the README in the product/install/jUDDI-registry directory, to prepopulate your own jUDDI database.
In the event that a service fails or does not shut down cleanly, it is possible that stale entries may persist within a registry. You will have to remove these manually.
For more information see the wiki http://labs.jboss.com/wiki/JudyEvaluation
JBossESB user forum: http://www.jboss.com/index.html?module=bb&op=viewforum&f=246
When you deploy the juddi.war that ship with our esb, you enable access through SOAP, which means that you can use any uddi brower. You can use http://uddibrowser.org
Chapter 4
What is a Rule
Service?
The JBoss ESB Rule Service support allows you to deploy rules created in JBoss Drools as services on the ESB. This is beneficial, because it means you don't have to develop as much client code to integrate rules into your application environment, and rules can be accessed as part of a action chain or orchestarted business process. To understand these types of services, you should first learn about JBoss Drools.
Rule Services are supported by the BusinessRuleProcessor action class and the DroolsRuleService, which implements the RuleService interface. While it is possible to use rule engines other than JBoss Drool, only JBoss Drools is supported out the the box. The BusinessRuleProcessor supports rules loaded from the classpath that are defined in .drl files, .dsl and dslr files (domain specific language support), and .xls (decision table support) files. These are primarily for testing, prototypes, and very simple rule services. There is no way to specify multiple rule files in the jboss-esb.xml file, so complex rule services need to use the Drools RuleAgent. The RuleService uses the RuleAgent to access rule packages from the Drools BRMS or local file system. These rule packages can contain thousands of rules, created through the Drools BRMS business rule editor, imported DRL files, rules written in a Domain Specific Language, and rules from Decision Tables. Use of the Drools RuleAgent is the recommended approach for production systems.
The BusinessRuleProcessor action supports both Drools stateless and stateful execution models. Most rule services will be stateless. That is, a message will be sent to the rule service that includes all the facts to be inserted into the rule engine in the message body, the rules will execute, and update either the message and / or the facts. Stateful execution takes place over time, with several messages being sent to the rule service, the rules being executed each time, the message and / or facts being updated each time, and a final message that tells the rule service to dispose of the statefull session working memory of the rule engine. There are limitations in this configuration, namely that there can only be a single (stateful) rule service in the message flow. This may change in the future, when there are better ways to identify a stateful conversation over the ESB.
Rule Services using Drools
The Rule Service support in the JBossESB uses JBossRules/Drools as its rule engine. JBossESB integrates with Drools through
The BusinessRuleProcessor action class
Rules written in Drools drl, dsl, decision table, or business rule editor.
The EsbMessage
The EsbMessage content, i.e., the objects in the message, which is the data going into the rules engine.
When a message gets send to the BusinessRuleProcessor, a certain rule set will execute over the objects in the message, and update those objects and / or the message.
A rule set can be created using the Red Hat Developer Studio which includes a plug-in for JBoss Drools, or with Eclispe 3.3 and the plugin installed (see Drools download site for the plugin). Since the message is added as a global, you need to add jbossesb-rosetta.jar to your Drools project.
You can also write your rules using Drools BRMS business rule editor. When using the Drools BRMS, it is not necessary to add the ESB Message class to the imports, as long as jbossesb-rosetta.jar is somewhere on the classpath of the BRMS web application.
For a detailed discussion on rule creation and the Drools language itself please see the Drools documention.
For the most part, rules can be written without regard to their deployment on the ESB as a service. There are a few caveats however:
1) All rules deployed as a rule service must define the ESBMessage as a global, i.e.,
#declare any global variables here
global org.jboss.soa.esb.message.Message;
The rationale for this is that most rule services will want to update the message as a way of communicating results to other services in the flow, so the BusinessRuleProcessor / DroolsRuleService will always set the message as a global.
2) The BusinessRuleProcessor / DroolsRuleService does not provide a means to set globals in the jboss-esb.xml and have them set in working memory. This would have made for additional configuration support in the jboss-esb.xml, and could be supported in the future. For now, if additional globals (other than the ESBMessage) need to be set, they can be done in higher salience rule. E.g.,
rule "Set a global"
salience 100
when
then
drools.getWorkingMemory().setGlobal("foo",new Foo());
end
3) The ESBRuleService does not provide a means to start a RuleFlow from the rule service. This also would have made for additional configuration support in the jboss-esb.xml, and could be supported in the future. For now, if a RuleFlow needs to be started, this can be done in higher salience rule. E.g.,
rule "Start a ruleflow"
salience 100
when
then
drools.startProcess("processId");
end
The consumer of a rule service has little to worry about. In a rule service environment there is no need for the consumer to worry about creating rulebases, creating working memories, inserting facts, or firing the rules. Instead the consumer just has to worry about adding facts to the message, and possibly some properties to the message.
In some cases the client is ESB aware, and will add the objects to the message directly:
MessageFactory factory = MessageFactory.getInstance();
message = factory.getMessage(MessageType.JAVA_SERIALIZED);
order = new Order();
order.setOrderId(0);
order.setQuantity(20);
order.setUnitPrice(new Float("20.0"));
message.getBody().add("Order", order);
In other cases the data may be in an XML message, and a transformation service will be added to the message flow to transform the XML to POJOs before the rule service is invoked.
Using stateful rule execution requires a few properties to be added the messages. For the first message,
message.getProperties().setProperty("dispose", false);
message.getProperties().setProperty("continue", false); // this is the default
For all the subsequest messages but the final message,
message.getProperties().setProperty("dispose", false);
message.getProperties().setProperty("continue", true);
For the final message,
message.getProperties().setProperty("dispose", true); // this is the default
message.getProperties().setProperty("continue", true);
These can be added directly by an ESB aware client. A non-ESB aware client would have to communicate the position of the message (first, ongoing, last) in the data, and an action class would need to be added to the pipeline to add the properties to the ESB message (see quickstarts/business_ruleservice_stateful for an example of this type of service).
Configuration of a rule service is in the jboss-esb action element for the service. Several configuration parameters are required or optional
The action class and name is required:
<action class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="OrderDiscountRuleService">
This configures the action class and its name. The name is user defined.
One of the following is also required
<property name="ruleSet" value="drl/OrderDiscount.drl" />
for specifying a drl file, or
<property name="ruleSet" value="dsl/approval.dslr" />
<property name="ruleLanguage" value="dsl/acme.dsl" />
for specifying a dsl and dslr (domain specific language) files , or
<property name="decisionTable" value="PolicyPricing.xls" />
for specifying a decisionTable on the classpath, or
<property name="ruleAgentProperties" value="brmsdeployedrules.properties" />
for specifying a properties file on the classpath that tells the rule agent how to find the rule package. This could specify a url or a local file system.
Several example configurations follow:
Example 1: Rules are in a drl, execution is stateless.
<action
class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="OrderDiscountRuleService"
<property name="ruleSet"
value="drl/OrderDiscount.drl" />
<property name="ruleReload" value="true" />
<property name="object-paths">
<object-path esb="body.Order" />
</property>
</action>
Example 2: Rules are in a drl, execution is stateful.
In this scenario the client may send multiple messages over time to the rule service. For example, the first message may contain a customer object, and the next several messages contain orders for that customer. Each time a message is received, the rules will be fired. On the final message, the client can add a property to the message to tell the rule service to dispose of the working memory.
<action class="org.jboss.soa.esb.actions.BusinessRulesProcessor"
name="OrderDiscountMultipleRuleServiceStateful">
<property name="ruleSet"
value="drl/OrderDiscountOnMultipleOrders.drl" />
<property name="ruleReload" value="false" />
<property name="stateful" value="true" >
<property name="object-paths">
<object-path esb="body.Customer" />
<object-path esb="body.Order" />
</property>
</action>
Example 3: Rules are in a Domain Specific Language, execution is stateless.
<action class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="PolicyApprovalRuleService"
<property name="ruleSet" value="dsl/approval.dslr" />
<property name="ruleLanguage" value="dsl/acme.dsl" />
<property name="ruleReload" value="true" />
<property name="object-paths">
<object-path esb="body.Driver" />
<object-path esb="body.Policy" />
</property>
</action>
Example 4: Rules are in a DecisionTable, execution is stateless.
<action class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="PolicyPricingRuleService"
<property name="decisionTable"
value="decisionTable/PolicyPricing.xls" />
<property name="ruleReload" value="true" />
<property name="object-paths">
<object-path esb="body.Driver" />
<object-path esb="body.Policy" />
</property>
</action>
Example 5: Rules are in the BRMS, execution is stateless.
<action class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="RuleAgentPolicyService"
<property name="ruleAgentProperties"
value="ruleAgent/brmsdeployedrules.properties" />
<property name="object-paths">
<object-path esb="body.Driver" />
<object-path esb="body.Policy" />
</property>
</action>
The action attributes to the action tag are show in Table 1. The attributes specify which action is to be used and which name this action is to be given.
|
Attribute |
Description |
|---|---|
|
Class |
org.jboss.soa.esb.actions.BusinessRulesProcessor |
|
Name |
Custom action name |
Table 1. BusinessRuleProcessor action configuration attributes.
The action properties are shown in Table 2. The properties specify the set of rules (ruleSet) to be used in this action.
|
Property |
Description |
|---|---|
|
ruleSet |
Optional reference to a file containing the Drools ruleSet. The set of rules that is used to evaluate the content. Only 1 ruleSet can be given for each rule service instance. |
|
ruleLanguage |
Optional reference to a file containing the definition of a Domain Specific Language to be used for evaluating the rule set. If this is used, the file in ruleSet should be a dslr file. |
|
ruleReload |
Optional property which can be to true to enable 'hot' redeployment of rule sets. Note that this feature will cause some overhead on the rules processing. Note that rules will also reload if the .esb archive in which they live is redeployed. |
|
decisionTable |
Optional reference to a file containing the definition of a spreadsheet containing rules. |
|
ruleAgentProperties |
Optional reference to a properties file containing the location (URL or file path) to the compiled rule package(s). Note there is no need to specify ruleReload with a ruleAgent, since this is controlled through the properties file. |
|
stateful |
Optional property which can be to true to specify that the rule service will receive multiple messages over time that will add fact to the rule engine working memory and re-execute the rules. |
|
|
|
|
object-paths |
Optional property to pass Message objects into Drools WorkingMemory. |
Table 2. BusinessRuleProcessor action configuration properties.
Note that JBossRules treats objects as shallow objects to achieve highly optimized performance, so what if you want to evaluate an object deeper in the object tree? An the optional 'object-paths' property can be used, which results in the extraction of objects from the message, using an “ESB Message Object Path”. MVEL is used to extract the object and the path used should follow the syntax:
location.objectname.[beanname].[beanname]...
where,
location : one of {body, header, properties, attachment}
objectname: name of the object name, attachments can be named or numbered, so for attachments this can be a number too.
beannames: optionally you traverse a bean graph by specifying bean names
examples :
properties.Order, gets the property object named "Order"
attachment.1, gets the first attachment Object
attachment.FirstAttachment, gets the attachment named 'FirstAttachment'
attachment.1.Order, gets getOrder() return object on the attached Object.
body.Order1.lineitem, obtains the object named "Order1" from the body of the message. Next it will call getLineitem() on this object. More elements can be added to the query to traverse the bean graph.
It is important to remember that you have to add java import statements on the objects you import into your rule set.
Finally, the Object Mapper can flatten out entire collections. For example a collectoin Orders will be unrolled, and each order object inserted into working memory.
It is recommended that you package up your code into units of functionality, using .esb packages. The idea is to package up your routing rules alongside the rule services that use the rule sets. Figure 3 shows a layout of the business_rules_service quickstart to demonstrate a typical package.
.Quickstart_business_rules_service.esb
| jbm-queue-service.xml | MyBusinessRules.drl | MyBusinessRulesDiscount.drl | MyRoutingRules.drl | smooks-res.xml | +---META-INF | deployment.xml | jboss-esb.xml | MANIFEST.MF | \---org \---jboss \---soa \---esb \---dvdstore | Customer.class | OrderHeader.class | OrderItem.class \---samples \---quickstart \---businessrules | ReviewMessage.class \---test SendJMSMessage.class
Figure 3. Typical .esb archive which uses Drools.
Finally make sure to deploy and reference the jbrules.esb in your deployment.xml.
<jbossesb-deployment>
<depends>jboss.esb:deployment=jbrules.esb</depends>
</jbossesb-deployment>Chapter 6
What is Content-Based
Routing?
Typically, information within the ESB is conveniently packaged, transferred, and stored in the form of a message. Messages are addressed to Endpoint References (services or clients), that identify the machine/process/object that will ultimately deal with the content of the message. However, what happens if the specified address is no longer valid? For example, the service has failed or been removed from service? It is also possible that the service no longer deals with messages of that particular type; in which case, presumably some other service still handles the original function, but how should the message be handled? What if other services besides the intended recipient are interested in the message's content? What if no destination is specified?
One possible solution to these problems is Content-Based Routing. Content-based routing seeks to route messages, not by a specified destination, but by the actual content of the message itself. In a typical application, a message is routed by opening it up and applying a set of rules to its content to determine the parties interested in its content.
The ESB can determine the destination of a given message based on the content of that message, freeing the sending application from having to know anything about where a message is going to end up.
Content-based routing and filtering networks are extremely flexible and very powerful. When built upon established technologies such as MOM (Message Oriented Middleware), JMS (Java Message Services), and XML (Extensible Markup Language) they are also reasonably easy to implement.
Content-based routing systems are typically built around two types of entities: routers (of which there may be only one) and services (of which there is usually more than one). Services are the ultimate consumers of messages. How services publish their interest in specific types of messages with the routers is implementation dependent, but some mapping must exist between message type (or some aspect of the message content) and services in order for the router to direct the flow of incoming messages.
Routers, as their name suggests, route messages. They examine the content of the messages they receive, apply rules to that content, and forward the messages as the rules dictate.
In addition to routers and services, some systems may also include harvesters, which specialize in finding interesting information, packaging it up as a formatted message before sending it to a router. Harvesters mine many sources of information including mail transfer agent message stores, news servers, databases and other legacy systems.
The diagram below illustrates a typical CBR architecture using an ESB. At the heart of the system, represented by the cloud, is the ESB. Messages are sent from the client into the ESB, which directs them to the Router. This is then responsible for sending the messages to their ultimate destination (or destinations, as shown in this example).
Chapter 7
Content Based Routing using Drools
The Content Based Router (CBR) in the JBossESB uses JBossRules/Drools as its evaluation engine. JBossESB integrates with Drools through three different routing action classes,
a routing rule set, written in Drools drl (and optionally dsl) language.
The EsbMessage content, either the serialized XML, or objects in the message, which is the data going into the rules engine.
destination(s) which is the result coming out of the rules engine.
When a message gets send to the CBR, a certain rule set will evaluate the message content and return a set of Service destinations. We discuss how a target rule set can be targeted, how the message content is evaluated and what is done with the destination results.