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.2 Milestone Release 2
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
Contents iv
About This
Guide 5
What This Guide Contains 5
Audience 5
Prerequisites 5
Organization 5
Documentation Conventions 6
Additional Documentation 7
Contacting Us 7
Pre-Packed Actions 8
Transformers & Converters 8
ByteArrayToString 8
LongToDateConverter 9
ObjectInvoke 9
ObjectToCSVString 10
ObjectToXStream 10
SmooksTransformer 11
XStreamToObject 12
Business Process Management 13
jBPM - CommandInterpreter 13
Scripting 14
GroovyActionProcessor 14
Routing 15
Aggregator 15
ContentBasedRouter 15
StaticRouter 16
Notifier 16
Miscellaneous 17
SystemPrintln 17
Developing Custom Actions 18
About
This Guide
The goal of this document is to:
Provide a catalog of all Message Action implementations provided with JBoss ESB (out-of-the-box).
Provide a guide for developing custom Action implementations.
This guide is targeted at developers.
None.
See document index.
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) |
Note: |
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.2 Milestone Release 2 documentation set:
JBoss ESB 4.2 Milestone Release 2 Getting Started Guide: Quick guide to getting started with JBoss ESB..
JBoss ESB 4.2 Milestone Release 2 Programmers Guide: How to use JBossESB.
JBoss ESB 4.2 Milestone Release 2 Administration Guide: How to manage the ESB.
JBoss ESB 4.2 Milestone Release 2 Services Guides: Various documents related to the services available with the ESB.
JBoss ESB 4.2 Milestone Release 2 Trailblazer Guide: Provides guidance for using the trailblazer example.
JBoss ESB 4.2 Milestone Release 2 Release Notes: Information on the differences between this release and previous releases.
Questions or comments about JBoss ESB 4.2 Milestone Release 2 should be directed to our support team.
Chapter 1
Pre-Packed Actions
This section provides a catalog of all Actions that are supplied out-of-the-box with JBoss ESB (“pre-packed”).
Converters/Transformers are a classification of Action Processor responsible for transforming a message (payload, headers, attachments etc) from a format produced by one message exchange participant, into a format that is consumable by anopther message exchange participant.
Takes a byte[] based message payload and converts it into a java.lang.String object instance, bound to the message under the name "org.jboss.soa.esb.actions.current.after".
Input Type |
byte[] |
Input Location |
|
Output Type |
java.lang.String |
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.ByteArrayToString |
Properties |
|
Sample Config |
<action name="transform" class="org.jboss.soa.esb.actions.converters.ByteArrayToString"> <property name="encoding" value="UTF-8" /> </action> |
Takes a long based message payload and converts it into a java.util.Date object instance, bound to the message under the name "org.jboss.soa.esb.actions.current.after".
Input Type |
java.lang.Long/long |
Input Location |
|
Output Type |
java.util.Date |
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.LongToDateConverter |
Properties |
None |
Sample Config |
<action name="transform"
class="org.jboss.soa.esb.actions.converters.LongToDateConverter" />
|
Takes the Object bound to a message under the name "org.jboss.soa.esb.actions.current.after" and supplies it to a configured “processor” for processing. The processing result is bound to the message under the name "org.jboss.soa.esb.actions.current.after" (overwriting the input parameter).
Input Type |
User Object |
Input Location |
|
Output Type |
User Object |
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.ObjectInvoke |
Properties |
|
Sample Config |
<action name="invoke" class="org.jboss.soa.esb.actions.converters.ObjectInvoke"> <property name="class-processor" value="org.jboss.MyXXXProcessor" /> <property name="class-method" value="processXXX" /> </action> |
Takes the Object bound to a message under the name "org.jboss.soa.esb.actions.current.after" and converts it into a Comma Separated Value (CSV) String based on the supplied message object and a comma-separated "bean-properties” list property.
Input Type |
User Object |
Input Location |
|
Output Type |
java.lang.String |
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.ObjectToCSVString |
Properties |
|
Sample Config |
<action name="transform" class="org.jboss.soa.esb.actions.converters.ObjectToCSVString"> <property name="bean-properties" value="name,address,phoneNumber" /> <property name="fail-on-missing-property" value="true" /> </action> |
Takes the Object bound to a message under the name "org.jboss.soa.esb.actions.current.after" and converts it into XML using the XStream processor.
Input Type |
User Object |
Input Location |
|
Output Type |
java.lang.String |
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.ObjectToXStream |
Properties |
|
Sample Config |
<action name="transform" class="org.jboss.soa.esb.actions.converters.ObjectToXStream"> <property name="class-alias" value="MyAlias" /> <property name="exclude-package" value="true" /> </action> |
Performs a message transformation based on the specified message exchange.
Input Type |
java.lang.String |
Input Location |
|
Output Type |
|
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.SmooksTransformer |
Properties |
|
Sample Config |
<action name="transform" class="org.jboss.soa.esb.actions.converters.SmooksTransformer"> <property name="from" value="DVDStore:OrderDispatchService" /> <property name="from-type" value="text/xml:fullFillOrder" /> <property name="to" value="DVDWarehouse_1:OrderHandlingService" /> <property name="to-type" value="text/xml:shipOrder" /> </action> |
See the MessageTransformation.pdf for more details on the SmooksTransformer.
Takes the XML bound to a message under the name "org.jboss.soa.esb.actions.current.after" and converts it into an Object using the XStream processor.
Input Type |
java.lang.String |
Input Location |
|
Output Type |
User Object (specified by “incoming-type” property) |
Output Location |
|
Class |
org.jboss.soa.esb.actions.converters.XStreamToObject |
Properties |
|
Sample Config |
<action name="transform" class="org.jboss.soa.esb.actions.converters.XStreamToObject"> <property name="class-alias" value="MyAlias" /> <property name="exclude-package" value="true" /> <property name="incoming-type" value="com.acme.MyXXXClass" /> </action> |
Expects the argument to be a command message and tries to execute the corresponding jBPM api invocation. If Call in message header contains a replyToEpr, will send response to it.
jBPM configuration files (jbpm.cfg.xml and hibernate.cfg.xml) must be present where the Jbpm.Configuration.getInstance() expects them to be found.
At present time, the following operations are implemented :
deployProcessDefinition
,newProcessInstance
,signalProcess
,signalToken
,getProcessInstanceVariables
,setProcessInstanceVariables
,getTokenVariables
,setTokenVariables
,hasInstanceEnded
Input Type |
org.jboss.soa.esb.message.Message generated by AbstractCommandVehicle.toCommandMessage() |
Input Location |
|
Output Type |
Message – output of util.jbpm.CommandVehicle.toCommandMessage() containing result of jBPM api call |
Output Location |
|
Class |
org.jboss.soa.esb.actions.jbpm.CommandInterpreter |
Properties |
|
Sample Config |
<action name="process" class="org.jboss.soa.esb.actions.jbpm.CommandInterpreter"> </action> |
Scripting Action Processors support definition of action processing logic via Scripting languages.
Executes a Groovy action processing script, receiving the message and action configuration as input.
Script Bindings |
|
Class |
org.jboss.soa.esb.actions.scripting.GroovyActionProcessor |
Properties |
|
Sample Config |
<action name="process" class="org.jboss.soa.esb.scripting.GroovyActionProcessor"> <property name="script" value="/scripts/ActionXProcessor.groovy" /> </action> |
Routing Actions support conditional routing of messages between two or more message exchange participants.
Message aggregation action. An implementation of the Aggregator Enterprise Integration Pattern.
Class |
org.jboss.soa.esb.actions.Aggregator |
Properties |
|
Sample Config |
<action class="org.jboss.soa.esb.actions.Aggregator" name="Aggregator"> <property name="timeoutInMillies" value="60000"/> </action> |
This action relies on all messages having the correct correlation data. This data is set on the message as a property called “aggregatorTag” (Message.Properties). See the ContentBasedRouter and StaticRouter actions.
The data has the following format:
[UUID] “:” [message-number] “:” [message-count]
If all the messages have been received by the aggregator, it returns a new Message containing all the messages as part of the Message.Attachment list (unnamed), otherwise the action returns null.
Content (plus rules) based message routing action.
Class |
org.jboss.soa.esb.actions.ContentBasedRouter |
Properties |
|
“process” methods |
|
Sample Config |
<action process=”split” name="ContentBasedRouter” class="org.jboss.soa.esb.actions.ContentBasedRouter"> <property name="ruleSet" value="MyESBRules-XPath.drl"/> <property name="ruleLanguage" value="XPathLanguage.dsl"/> <property name="ruleReload" value="true"/> <property name="destinations"> <route-to destination-name="express" service-category="ExpressShipping" service-name="ExpressShippingService"/> <route-to destination-name="normal" service-category="NormalShipping" service-name="NormalShippingService"/> </property> </action> |
See ContentBasedRouting.pdf for more details on the Content Based Routing.
Static message routing action. This is basically a simplified version of the Content Based Router, accept it doesn't support content based routing rules.
Class |
org.jboss.soa.esb.actions.ContentBasedRouter |
Properties |
|
“process” methods |
See the Aggregator action. |
Sample Config |
<action name="routeAction” class="org.jboss.soa.esb.actions.StaticRouter"> <property name="destinations"> <route-to service-category="ExpressShipping" service-name="ExpressShippingService"/> <route-to service-category="NormalShipping" service-name="NormalShippingService"/> </property> </action> |
Send notifications to list specified in configuration. This class has a dummy process(Message) method that simply returns the argument.
Intended as example of what's needed to have your own notifier. You would typically extend this class and override notifyOk() and notifyError() methods to produce the desired output.
If you wish the ability to notify of success or failure at each step of the action processing pipeline, use the “okMethod” and “exceptionMethod” attributes in each <action> element instead of having an <action> that uses the Notifier class.
Class |
org.jboss.soa.esb.actions.Notifier |
Properties |
NotificationList subtree indicating targets |
Sample Config |
|
Miscellaneous Action Processors.
Simple action for printing out the contents of a message (ala System.out.println).
Will attempt to format the message contents as XML.
Input Type |
java.lang.String |
Input Location |
|
Class |
org.jboss.soa.esb.actions.SystemPrintln |
Properties |
|
Sample Config |
<action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln"> <property name="message" value="Message before action XXX" /> </action> |
Chapter 2
Developing Custom Actions
To implement a custom Action Processor, simply implement the org.jboss.soa.esb.actions.ActionPipelineProcessor interface.
This interface supports implementation of stateless actions that have a managed lifecycle. A single instance of a class implementing this interface is instantiated on a per pipeline basis (i.e. per action configuration). This means you can cache resources needed by the action in the initialise method, and clean them up in the destroy method.
The implementing class should process the message from within the process method implementation.
As a convenience, you should simple extend the org.jboss.soa.esb.actions.AbstractActionPipelineProcessor.
Example:
public class ActionXXXProcessor extends AbstractActionPipelineProcessor { public void initialise() throws ActionLifecycleException { // Initialise resources... } public Message process(final Message message) throws ActionProcessingException { // Process messages in a stateless fashion... } public void destroy() throws ActionLifecycleException { // Cleanup resources... } } |
Actions generally act as templates that require external configuration to perform their tasks. For example, a PrintMessage action might take a property named 'message' to indicate what to print and a property 'repeatCount' to indicate the number of times to print it. The action configuration in the jboss-esb.xml file might look like this:
|
The default method for loading property values in an action implementation is the use of a ConfigTree instance. The ConfigTree provides a DOM-like view of the action XML. By default, actions are expected to have a public constructor that takes a ConfigTree as a parameter. For example:
|
Another approach to setting action properties is to add setters on the action that correspond to the property names and allow the framework to populate them automatically. In order to have the action bean auto-populated, the action class must implement the org.jboss.soa.esb.actions.BeanConfiguredAction marker interface. For example, the following class has the same behavior as the one above.
|
Note that the Integer parameter in setRepeatCount() is automatically converted from the String representation specified in the XML.
The BeanConfiguredAction method of loading properties is a good choice for actions that take simple arguments, while the ConfigTree method is better when you need to deal with the XML representation directly.
JBESB-MAG-