Versions Compared

Key

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

...

  1. The ServiceMix container reads the servicemix.xml file and sees it needs to instantiate a FilePoller.
  2. The container calls the init() method of FilePoller as well as the init() methods of its parents.
  3. The container determines that FilePoller is an MBean and, therefore, calls the start() method of FilePoller, which it inherits from its parent PollingComponentSupport.
  4. The start() method will:
    a. Create a timerTask.
    b. Schedule the the timerTask at a fixed rate. The start() method uses the "timer" (created in the init method) to schedule the timerTask at a fixed rate: timer.scheduleAtFixedRate(timerTask, firstTime, period). Recall "period" is a property of FilePoller. It was assigned the value of 1000ms by dependency injection from the servicemix.xml file.
    c. timer will call the run() method of the timerTask periodically. timerTask's run method() is defined inline. It will get the workManager object (see below for details).
    e. The workManager will call scheduleWork(PollingComponentSupport.this). Note: it passes in PollingComponent support, which by virtue of its inheritance hierarchy, is also of type "Work", which is a "Runnable."
    f. workManager.scheduleWork(Work) will likely create or get a Thread, passing in a Runnable object, i.e. PollingComponentSupport, and call its run() method
    g. PollingComponent's run() method calls poll(), which is implemented in FilePoller.
    h. From this point on the call sequence can be followed in FilePoller...
    i. The start() method of PollingComponentSupport, will eventually calls super.start(), which propagates up to call the start() method of BaseLifeCycle, which sets the component state to "RUNNING."

Eventually, one of the threads that is polling (looking) for a file in the inbox directory will see a file in the inbox directory. It will use workManager's thread pool to get a thread for processing the file. Processing the file consists of streaming it in 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 spring workmanager SpringWorkManager is a spring bean, which by default, Spring bean. By default when a spring Spring bean starts, the properties are set, which are defined in the service.xml file. A method called "afterpropertiesset" and then the afterPropertiesSet() is called by the container.

The SprintWorkManager workManager is used in two ways:The work manager to allocate threads. The FilePoller asks for threads from the workManager for two operations:

  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

...

  1. a file (read, normalize and send to NMR). The

...

  1. workManager calls a scheduleWork() method

...

  1. which is non-blocking. Therefore, if multiple files need to be

...

  1. processed,

...

  1. ilePoller can continue making

...

  1. requests to the

...

  1. workManager to schedule work

...

1. The Timer object schedules a TimerTask

...

  1. .

Related Documentation

For more information on the following topics please see:

...