Versions Compared

Key

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

Overview of the ServiceMix

...

File Binding Example

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: Use Case for File Binding.

...

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

Code Block

 
 
ServiceMix ESB: 1.0.1

Loading ServiceMix from file: servicemix.xml
[INFO] XmlBeanDefinitionReader - -Loading XML bean definitions from file [C:\Program Files\servicemix-1.0.1\examples\file-binding\servicemi.xml]
[INFO] FileSystemXmlApplicationContext - -Bean factory for application context [org.springframework.context.support.FileSystemXmlApplication
Context;hashCode=7486844]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [workManager,jbi]; root of BeanFactory hierarchy
[INFO] FileSystemXmlApplicationContext - -2 beans defined in application context 
[org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=7486844]
[INFO] CollectionFactory - -JDK 1.4+ collections available
[INFO] CollectionFactory - -Commons Collections 3.x available
[INFO] FileSystemXmlApplicationContext - -Unable to locate MessageSource with name 'messageSource': using default [org.springframework.conte
xt.support.DelegatingMessageSource@1d6776d]
[INFO] FileSystemXmlApplicationContext - -Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using defaul
t [org.springframework.context.event.SimpleApplicationEventMulticaster@4fce71]
[INFO] DefaultListableBeanFactory - -Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanF
actory defining beans [workManager,jbi]; root of BeanFactory hierarchy]
[INFO] DefaultListableBeanFactory - -Creating shared instance of singleton bean 'workManager'
[INFO] DefaultListableBeanFactory - -Creating shared instance of singleton bean 'jbi'
Created MBeanServer with ID: 203c31:106bd250a5b:-7fff:Lisas:1
[INFO] SpringInitialContextFactory - -Loading JNDI context from: class path resource [jndi.xml]
[INFO] XmlBeanDefinitionReader - -Loading XML bean definitions from class path resource [jndi.xml]
[INFO] XmlBeanFactory - -Creating shared instance of singleton bean 'jndi'
RMIConnectorServer started at: service:jmx:rmi://lisas/jndi/rmi://localhost:1099/defaultJBIJMX
[INFO] JBIContainer - -ServiceMix JBI Container (http://servicemix.org/) name: defaultJBI running version: ServiceMix.
[INFO] JBIContainer - -Activating component for: [container=defaultJBI,name=fileSender,id=fileSender] with service: fileSender component: org.servicemix.components.file.FileWriter@b1cc87
[INFO] ComponentContextImpl - -Component: fileSender activated endpoint: fileSender : fileSender
[INFO] JBIContainer - -Activating component for: [container=defaultJBI,name=filePoller,id=filePoller] with service: filePoller component: or
g.servicemix.components.file.FilePoller@183e7de
[INFO] ComponentContextImpl - -Component: filePoller activated endpoint: filePoller : filePoller
[INFO] DeliveryChannel - -default destination serviceName for filePoller = fileSender

...

  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: (See: PollingComponentSupport.java code fragment below)
    A. Create a timerTask.
    B. Schedule 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. This run() method will get the workManager object (see below for details).
    D. The workManager will call "scheduleWork(PollingComponentSupport.this)". _Note:_it passes in PollingComponent support, which by virtue of its inheritance hierarchy, is of type "Work", which is a "Runnable" object.
    E. "workManager.scheduleWork(Work)" will get a Thread, passing in a Runnable object, i.e. PollingComponentSupport, and call its run() method.
    F. PollingComponent's run() method calls poll(), which is implemented in FilePoller.
    G. From this point on the call sequence can be followed in FilePoller...
    H. The start() method of PollingComponentSupport, will eventually call super.start(), which propagates up to call the start() method of BaseLifeCycle, which sets the component state to "RUNNING."

...

Code Block
titlePollingComponentSupport.java
borderStylesolid
  timerTask  =protected newvoid TimerTaskinit() throws JBIException {
     public   voidif run(scheduler == null) {
          try {  scheduler = new Scheduler(true);
        }
        if getWorkManager().scheduleWork(PollingComponentSupport.this);scheduleIterator == null) {
        	scheduleIterator  }= new PollScheduleIterator();
        }
  catch (Throwable e) {
   if (workManager == null) {
         log.error("Failed to schedule work:ComponentContextImpl "context + e, e= (ComponentContextImpl) getContext();
          }
  workManager   }= context.getWorkManager();
  };
  if (firstTime != null) {}
        timersuper.scheduleAtFixedRate(timerTask, firstTime, periodinit();
  }
  else {
  
   timer.scheduleAtFixedRate(timerTask, delay, period);
  }
}
super.start();

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.

...