Versions Compared

Key

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

...

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 inbox directory, retrieves it, sends 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.

Info
titleNote

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

...

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 Normalized Message Router ( NMR ) to the fileSender component per the specified "destinationService" which . The destinationService is specified in the servicmixservicemix.xml file in as an attribute the filePoller component. In this case 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, in this case the outbox directory. This component creates the filename to copy the file to 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 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 itits' s work, however, it is not using a thread from the workManager's thread pool.

...

  1. The timerTask uses threads from the thread pool to periodically check the inbox directoroy for files.
  2. The workManager will also allocate a thread to process a file (read, normalize and send to NMR). The workManager calls a scheduleWork() method which is non-blocking. Therefore, if multiple files need to be processed, ilePoller can continue making requests to the workManager to schedule work.

Summarizing, when the ServiceMix container instantiates an MBean it firsts sets the property values if there are any, then calls the init() method of the class and its' parent classes, if applicable. Then it calls the start() method of the class.

Related Documentation

For more information on the following topics please see:

...