Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

File Binding Example

Overview

This document describes how to run ServiceMix's File Binding example and provides details about what it does. For information on the business use case, please refer to the last section: use case.

The File Binding example illustrates the following:

...

The File Binding XML file, servicemix.xml, contains two components and a supporting bean. One component waits for a file to be deposited into the the inboxdirectory, 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 the other component, which deposits it into an outbox directory. Please be aware that for the out-of-the-box example the input and output files are not necessarily binary identical as their XML DOM is processed; so for instance comments will be lost. The bean provides a thread pool to enhance the performance of the reading and processing of the files. Details about the components and bean are discussed below.

...

...

The file to be transmitted from the inbox to outbox must be in XML format.

...

Running the File Binding Example

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

...

...

where servicemix_install_dir is the directory in which ServiceMix was installed.

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

...

...

You need to download additional jars by running:

...

Then type:

...

...


After a few seconds, the sample_xxx.xml file will appear in the outbox directory. To see this open another command window and do a directory listing on the outbox directory, for example:

...

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

...

Add $SERVICEMIX_HOME/bin directory to $PATH variable to simplify execution of the example.

...

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

...



...

Image Modified

...



The logical flow of the program is:

...

Logging information is written to the console as files are transmitted. Typical output looks like the following:

...


...

Details

The following table provides more details about the function of each component and bean in the servicemix.xml file.

...

Eventually, one of the threads that is polling (see step G) for a file in the inbox directory will see a one. It will use workManager's thread pool to get a thread for processing the file. Processing the file consists of streaming it from inbox, creating a normalized message, and sending the message to the NMR.

...

...

workManager Details

workManager is a property of the FilePoller object. This property is defined by a local reference, the "ref" attribute in the servicemix.xml file. The local reference is a bean which instantiates org.activemq.work.SpringWorkManager.

...

The following diagram illustrates this:

...

...

Image Modified

...

Related Documentation

For more information on the following topics please see:


For a brief explanation of the XML tags in the servicemix.xml file, please see:

...