Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This document describes how to run ServiceMix's BPEL example and provides details about what it does. For information on the business use case, please refer to: Use Case for File BindingBPEL.

The BPEL example illustrates the following:

  • an example of declarative programming
  • how to interact with the file system
  • how to use a WorkManager thread pool

The XML code for the File Binding BPEL example is located in the ServiceMix installation directory under the examples\file-binding directory in the servicemix.xml file. It is recommended that you refer to the servicemix.xml file while reading this document.

The File Binding BPEL XML file, servicemix.xml, contains two components and a supporting bean. One component waits for a file to be deposited into the the inbox directory, retrieves it, creates a normalized message that contains the file, then sends the message to the Normalized Message Router (NMR). The NMR routes the file to another component, which deposits it into an outbox directory.

...

titleNote

...

.

Running the

...

BPEL Example

From a command shell, go to the File Binding BPEL example directory:

Code Block
cd [servicemix_install_dir]\examples\file-binding

where servicemix_install_dir is the directory in which ServiceMix was installed.

Before running the example, copy a test file into the inbox directory:

...

.

...

Then type:

Code Block
[servicemix_install_dir]\bin\servicemix servicemix.xml

OR

..\..\bin\servicemix servicemix.xml

...

If you would like to see more files moved from inbox to outbox, copy another file into the inbox directory. The file binding BPEL program continually polls (every 1000 ms) for new files, so any new file placed in inbox, will be transmitted to outbox.

Stopping the

...

BPEL Example

To terminate the File Binding BPEL example type "CTRL-C" in the command shell in which it is running and answer "y" to the "Terminate batch job (y/n)?" question.

...

The diagram below illustrates the logical flow of the program through the file binding BPEL components.



Panel
borderColor#ccc
titleFile Binding BPEL Logical Flow Diagram
borderStylesolid

...

Component or Bean ID

Description

filePoller

This component periodically checks the "inbox" directory looking for files. If there is a file or directory present, it adds the file to the "workingSet", which is a collection of files to be processed. The workManger is invoked to schedule the work of processing the file from the workingSet. Another thread is created and the processing of the file begins. Processing consists of marshalling the file (streaming it from disk into a normalized message). The normalized message is sent over the NMR to the fileSender component per the specified "destinationService". The destinationService is specified in the servicemix.xml file as an attribute the filePoller component. In this example, the "destinationService" is the fileSender component. Finally, after it has been processed, the filePoller deletes the file from the source directory.

fileSender

This component is the "destinationService" for the filePoller. It receives normalized messages from filePoller. The messages it receives are the files that filePoller has transferred to it via the NMR. It converts the normalized message to its original file format and sends it to the destination directory, the outbox directory. This component creates the filename to which to copy the file by concatenating the string "sample_" with the process id following by ".xml". The concatenated string is passed to the org.servicemix.expression.JaxenStringXPathExpression bean as an argument to the constructor, as can be seen by the constructor-arg value tag in the XML file.

workManager

This bean is used by the filePoller to increase the throughput of the application. The workManager is a thread pool whose size can be adjusted declaratively in the servicemix.xml file. The other components in the File Binding BPEL application ask the workManager for threads as needed. For example, threads are used by this application to periodically (every second) check for files in the inbox. Other threads are used to do the work of processing files (streaming them in, normalizing them, and sending them to the NMR). Note: The fileSender component also uses a thread to do its' work, however, it is not using a thread from the workManager's thread pool.

...

This section describes the start-up sequence and how the ServiceMix container interacts with the File Binding BPEL application. The Java class files are located in the servicemix-1.0.1.jar file in the ServiceMix installation directory. To look at the Java source code, unjar and decompile the .class files or download the source code. Please note: the downloadable source code is slightly different than the compiled binary code.

...