You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rodgersh <hu...@lmco.com> on 2013/09/12 22:31:10 UTC

Dynamic route not started when OSGi bundle it is in is uninstalled and then reinstalled

Hello -

I am using Camel v2.11.0.

I have a Camel dynamic route written in Java that is packaged in an OSGi
bundle deployed to Karaf v2.3.2. This route monitors a directory and when a
file is placed in the monitored directory the file is passed on to another
(custom) camel component. The bean containing this logic is defined in a
Spring XML file and the camel context injected into the bean. 

Everything works fine when the OSGi container comes up initially. The bundle
with the dynamic camel route is installed by default, I place a file in the
monitored directory and everything works. If I then uninstall the bundle and
reinstall it (or if I stop/start my OSGi container), when the bundle comes
back up it loads the dynamic route but Camel does not seem to start the
route again.

Any ideas what I might be doing wrong?

Here is the Spring XML file, the Java code, and log output from my
application showing the bundle and its execution of the camel dynamic route.

Thanks -

Hugh


Spring XML file:

<camel:camelContext id="camelContext">
  </camel:camelContext>
  
  
  <osgix:managed-service-factory id="contentDirectoryMonitor_MSF"
factory-pid="content.directorymonitor.ContentDirectoryMonitor"
    update-strategy="bean-managed" update-method="updateCallback">


    <osgix:interfaces>
      <beans:value>content.directorymonitor.DirectoryMonitor</beans:value>
    </osgix:interfaces>
   

    <beans:bean id="contentDirectoryMonitor"
class="content.directorymonitor.ContentDirectoryMonitor" 
        init-method="init" destroy-method="destroy">
        <beans:constructor-arg ref="camelContext" />
        
    	<beans:property name="monitoredDirectoryPath" value="" />
    	<beans:property name="directive" value="" />
    </beans:bean>
    
  </osgix:managed-service-factory>


Java code:

public ContentDirectoryMonitor(final CamelContext camelContext)  {
        this.camelContext = camelContext;
        LOGGER.trace("ContentDirectoryMonitor constructor done");
    }

    public void init() {
        LOGGER.trace("INSIDE: init()");
        
        if (routeCollection != null) {
            try {
                // This stops the route before trying to remove it
                LOGGER.debug("Removing " + routeCollection.size() + "
routes");
                camelContext.removeRouteDefinitions(routeCollection);
            } catch (Exception e) {
                LOGGER.warn(e.getMessage());
            }
        }
        else {
            LOGGER.debug("No routes to remove before configuring a new
route");
        }
        
        configureCamelRoute();
    }

    private void configureCamelRoute()
    {
        LOGGER.trace("ENTERING: configureCamelRoute");
        
        RouteBuilder routeBuilder = new RouteBuilder()   {
            @Override
            public void configure() throws Exception  {
                String inbox = "file:" + monitoredDirectory +
"?moveFailed=.errors";
                inbox += "&delete=true";
                LOGGER.debug("inbox = " + inbox);

                from(inbox)
                   .setHeader(Request.OPERATION, constant("create"))
                   .setHeader(Request.DIRECTIVE, constant(directive))
                   .setHeader(Request.CONTENT_URI, constant(""))
                   .to("content:framework");  // our custom camel component
"content"
            }
        };
                
        try {
            // Add the routes that will be built by the RouteBuilder class
above
            // to this CamelContext.
            // The addRoutes() method will instantiate the RouteBuilder
class above.
            camelContext.addRoutes(routeBuilder);
            camelContext.start();
            
            // Save the routes created by RouteBuilder so that they can be
            // stopped and removed later if the route(s) are modified by the 
            // administrator.
            this.routeCollection =
routeBuilder.getRouteCollection().getRoutes();
        }  catch (Exception e)  {
            LOGGER.warn("Unable to configure Camel route", e);
        }
        
        LOGGER.trace("EXITING: configureCamelRoute");
    }


Application's log output - in the "re-install" section you will see where
Camel says it started 0 of 0 routes, when for same bundle it started 1 route
when app was first started:


// User fills in form to create dynamic route

13:07:56,092 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   50 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | ContentDirectoryMonitor constructor done
13:07:56,095 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  125 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
13:07:56,095 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  136 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setDirective
13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  125 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  147 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setCopyIngestedFiles
13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  136 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setDirective
13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   64 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: init()
13:07:56,096 | DEBUG | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   81 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | No routes to remove before configuring a new route
13:07:56,097 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  158 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | ENTERING: configureCamelRoute
13:07:56,097 | DEBUG | eb-f79294e88283) | ContentDirectoryMonitor          |
onitor.ContentDirectoryMonitor$1  187 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | inbox = file:inbox?moveFailed=.errors&delete=true
13:07:56,161 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 2098 | 170 - org.apache.camel.camel-core -
2.11.0 | Route: route2 started and consuming from:
Endpoint[file://inbox?delete=true&moveFailed=.errors]
13:07:56,163 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1432 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is starting
13:07:56,163 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1467 | 170 - org.apache.camel.camel-core -
2.11.0 | Total 1 routes, of which 1 is started.
13:07:56,164 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1468 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) started in 0.000
seconds
13:07:56,165 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  215 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | EXITING: configureCamelRoute
13:07:56,165 | INFO  | eb-f79294e88283) | OsgiServiceFactoryBean           |
r.support.OsgiServiceFactoryBean  301 | 105 - org.springframework.osgi.core
- 1.2.1 | Publishing service under classes
[{ddf.content.core.directorymonitor.DirectoryMonitor}]

// Uninstall feature that has dynamic route

13:08:15,788 | INFO  | Timer-1          | OsgiBundleXmlApplicationContext  |
ractOsgiBundleApplicationContext  359 | 101 - org.springframework.context -
3.2.3.RELEASE | Unpublishing application context OSGi service for bundle DDF
:: Content :: Core :: Directory Monitor (content-core-directorymonitor)
13:08:15,789 | INFO  | Timer-1          | OsgiBundleXmlApplicationContext  |
pport.AbstractApplicationContext 1042 | 101 - org.springframework.context -
3.2.3.RELEASE | Closing
OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
config=osgibundle:/META-INF/spring/*.xml): startup date [Thu Sep 12 13:07:23
MST 2013]; root of context hierarchy
13:08:15,789 | INFO  | Timer-1          | DefaultListableBeanFactory       |
ort.DefaultSingletonBeanRegistry  444 | 99 - org.springframework.beans -
3.2.3.RELEASE | Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@53ee762f:
defining beans
[template,consumerTemplate,camelContext:beanPostProcessor,camelContext,contentDirectoryMonitor_MSF];
root of factory hierarchy
13:08:15,790 | INFO  | Timer-1          | DefaultListableBeanFactory       |
ort.DefaultSingletonBeanRegistry  444 | 99 - org.springframework.beans -
3.2.3.RELEASE | Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@543cc5dd:
defining beans
[ddf.content.core.directorymonitor.ContentDirectoryMonitor.7d5e0227-ee53-4471-9ceb-f79294e88283];
parent:
org.springframework.beans.factory.support.DefaultListableBeanFactory@53ee762f
13:08:15,790 | TRACE | Timer-1          | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   93 | 186 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: destroy()
13:08:15,791 | INFO  | Timer-1          | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1624 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is shutting down
13:08:15,792 | INFO  | Timer-1          | DefaultShutdownStrategy          |
mel.impl.DefaultShutdownStrategy  165 | 170 - org.apache.camel.camel-core -
2.11.0 | Starting to graceful shutdown 1 routes (timeout 300 seconds)
13:08:15,795 | INFO  | 3 - ShutdownTask | DefaultShutdownStrategy          |
ultShutdownStrategy$ShutdownTask  572 | 170 - org.apache.camel.camel-core -
2.11.0 | Route: route2 shutdown complete, was consuming from:
Endpoint[file://inbox?delete=true&moveFailed=.errors]
13:08:15,795 | INFO  | Timer-1          | DefaultShutdownStrategy          |
mel.impl.DefaultShutdownStrategy  213 | 170 - org.apache.camel.camel-core -
2.11.0 | Graceful shutdown of 1 routes completed in 0 seconds
13:08:15,799 | INFO  | Timer-1          | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1695 | 170 - org.apache.camel.camel-core -
2.11.0 | Uptime 19.636 seconds
13:08:15,799 | INFO  | Timer-1          | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1696 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is shutdown in
0.008 seconds
13:08:15,800 | INFO  | Timer-1          | ContextLoaderListener            |
BundleApplicationContextListener   60 | 106 -
org.springframework.osgi.extender - 1.2.1 | Application context succesfully
closed
(OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
config=osgibundle:/META-INF/spring/*.xml))

/////////////////// Re-install feature that has dynamic route 
/////////////////////////////////////

13:08:18,940 | INFO  | qtp798522203-258 | ultOsgiApplicationContextCreator |
ultOsgiApplicationContextCreator   67 | 106 -
org.springframework.osgi.extender - 1.2.1 | Discovered configurations
{osgibundle:/META-INF/spring/*.xml} in bundle [DDF :: Content :: Core ::
Directory Monitor (content-core-directorymonitor)]
13:08:18,945 | INFO  | xtenderThread-49 | OsgiBundleXmlApplicationContext  |
pport.AbstractApplicationContext  510 | 101 - org.springframework.context -
3.2.3.RELEASE | Refreshing
OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
config=osgibundle:/META-INF/spring/*.xml): startup date [Thu Sep 12 13:08:18
MST 2013]; root of context hierarchy
13:08:18,946 | INFO  | xtenderThread-49 | OsgiBundleXmlApplicationContext  |
ractOsgiBundleApplicationContext  365 | 101 - org.springframework.context -
3.2.3.RELEASE | Application Context service already unpublished
13:08:18,947 | INFO  | xtenderThread-49 | XmlBeanDefinitionReader          |
tory.xml.XmlBeanDefinitionReader  315 | 99 - org.springframework.beans -
3.2.3.RELEASE | Loading XML bean definitions from URL
[bundleentry://338.fwk458982688/META-INF/spring/beans.xml]
13:08:18,979 | INFO  | xtenderThread-49 | WaiterApplicationContextExecutor |
WaiterApplicationContextExecutor  243 | 106 -
org.springframework.osgi.extender - 1.2.1 | No outstanding OSGi service
dependencies, completing initialization for
OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
config=osgibundle:/META-INF/spring/*.xml)
13:08:18,982 | INFO  | xtenderThread-50 | DefaultListableBeanFactory       |
pport.DefaultListableBeanFactory  596 | 99 - org.springframework.beans -
3.2.3.RELEASE | Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@59414494:
defining beans
[camelContext:beanPostProcessor,camelContext,contentDirectoryMonitor_MSF];
root of factory hierarchy
13:08:18,991 | INFO  | xtenderThread-50 | ManagementStrategyFactory        |
gement.ManagementStrategyFactory   43 | 170 - org.apache.camel.camel-core -
2.11.0 | JMX enabled.
13:08:18,993 | INFO  | xtenderThread-50 | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1432 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is starting
13:08:18,997 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   50 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | ContentDirectoryMonitor constructor done
13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  125 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  136 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setDirective
13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  125 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  147 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setCopyIngestedFiles
13:08:19,000 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  136 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: setDirective
13:08:19,000 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   64 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | INSIDE: init()
13:08:19,000 | DEBUG | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor   81 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | No routes to remove before configuring a new route
13:08:19,000 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  158 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | ENTERING: configureCamelRoute
13:08:19,001 | DEBUG | rectoryMonitor]) | ContentDirectoryMonitor          |
onitor.ContentDirectoryMonitor$1  187 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | inbox = file:inbox?moveFailed=.errors&delete=true
13:08:19,013 | INFO  | xtenderThread-50 | faultManagementLifecycleStrategy |
erListenerManagerStartupListener  872 | 170 - org.apache.camel.camel-core -
2.11.0 | Load performance statistics enabled.
13:08:19,016 | INFO  | rectoryMonitor]) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1432 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is starting
13:08:19,016 | INFO  | rectoryMonitor]) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1467 | 170 - org.apache.camel.camel-core -
2.11.0 | Total 0 routes, of which 0 is started.
13:08:19,016 | INFO  | xtenderThread-50 | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1467 | 170 - org.apache.camel.camel-core -
2.11.0 | Total 0 routes, of which 0 is started.
13:08:19,016 | INFO  | rectoryMonitor]) | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1468 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) started in 0.000
seconds
13:08:19,017 | INFO  | xtenderThread-50 | OsgiSpringCamelContext           |
e.camel.impl.DefaultCamelContext 1468 | 170 - org.apache.camel.camel-core -
2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) started in 0.000
seconds
13:08:19,018 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
ymonitor.ContentDirectoryMonitor  215 | 338 - content-core-directorymonitor
- 2.3.0.SNAPSHOT | EXITING: configureCamelRoute
13:08:19,018 | INFO  | xtenderThread-50 | OsgiBundleXmlApplicationContext  |
ractOsgiBundleApplicationContext  327 | 101 - org.springframework.context -
3.2.3.RELEASE | Publishing application context as OSGi service with
properties
{org.springframework.context.service.name=content-core-directorymonitor,
Bundle-SymbolicName=content-core-directorymonitor,
Bundle-Version=2.3.0.SNAPSHOT}
13:08:19,018 | INFO  | rectoryMonitor]) | OsgiServiceFactoryBean           |
r.support.OsgiServiceFactoryBean  301 | 105 - org.springframework.osgi.core
- 1.2.1 | Publishing service under classes
[{ddf.content.core.directorymonitor.DirectoryMonitor}]
13:08:19,019 | INFO  | xtenderThread-50 | ContextLoaderListener            |
BundleApplicationContextListener   45 | 106 -
org.springframework.osgi.extender - 1.2.1 | Application context successfully
refreshed
(OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
config=osgibundle:/META-INF/spring/*.xml))





--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-route-not-started-when-OSGi-bundle-it-is-in-is-uninstalled-and-then-reinstalled-tp5739282.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic route not started when OSGi bundle it is in is uninstalled and then reinstalled

Posted by Andreas Gies <an...@wayofquality.de>.
Hi,

I am not sure we are looking at a Camel poblem. I am doing something 
similar in OSGi.
I listen to changes in a config directory. Any value changes gp into the 
Config Admin Service
and most of my routes are implemented as Managed Services.

As far as I can see config changes are picked up dynamically and bundle 
stop / restart does work.

This having said, in the beginning I was facing a slight problem with 
respect to recognize what file
had been changed reliably. Perhaps you have a similar problem - your 
config not being picked up in
a restart scenario ?

Best regards
Andreas

On 09/12/2013 10:31 PM, rodgersh wrote:
> Hello -
>
> I am using Camel v2.11.0.
>
> I have a Camel dynamic route written in Java that is packaged in an OSGi
> bundle deployed to Karaf v2.3.2. This route monitors a directory and when a
> file is placed in the monitored directory the file is passed on to another
> (custom) camel component. The bean containing this logic is defined in a
> Spring XML file and the camel context injected into the bean.
>
> Everything works fine when the OSGi container comes up initially. The bundle
> with the dynamic camel route is installed by default, I place a file in the
> monitored directory and everything works. If I then uninstall the bundle and
> reinstall it (or if I stop/start my OSGi container), when the bundle comes
> back up it loads the dynamic route but Camel does not seem to start the
> route again.
>
> Any ideas what I might be doing wrong?
>
> Here is the Spring XML file, the Java code, and log output from my
> application showing the bundle and its execution of the camel dynamic route.
>
> Thanks -
>
> Hugh
>
>
> Spring XML file:
>
> <camel:camelContext id="camelContext">
>    </camel:camelContext>
>    
>    
>    <osgix:managed-service-factory id="contentDirectoryMonitor_MSF"
> factory-pid="content.directorymonitor.ContentDirectoryMonitor"
>      update-strategy="bean-managed" update-method="updateCallback">
>
>
>      <osgix:interfaces>
>        <beans:value>content.directorymonitor.DirectoryMonitor</beans:value>
>      </osgix:interfaces>
>     
>
>      <beans:bean id="contentDirectoryMonitor"
> class="content.directorymonitor.ContentDirectoryMonitor"
>          init-method="init" destroy-method="destroy">
>          <beans:constructor-arg ref="camelContext" />
>          
>      	<beans:property name="monitoredDirectoryPath" value="" />
>      	<beans:property name="directive" value="" />
>      </beans:bean>
>      
>    </osgix:managed-service-factory>
>
>
> Java code:
>
> public ContentDirectoryMonitor(final CamelContext camelContext)  {
>          this.camelContext = camelContext;
>          LOGGER.trace("ContentDirectoryMonitor constructor done");
>      }
>
>      public void init() {
>          LOGGER.trace("INSIDE: init()");
>          
>          if (routeCollection != null) {
>              try {
>                  // This stops the route before trying to remove it
>                  LOGGER.debug("Removing " + routeCollection.size() + "
> routes");
>                  camelContext.removeRouteDefinitions(routeCollection);
>              } catch (Exception e) {
>                  LOGGER.warn(e.getMessage());
>              }
>          }
>          else {
>              LOGGER.debug("No routes to remove before configuring a new
> route");
>          }
>          
>          configureCamelRoute();
>      }
>
>      private void configureCamelRoute()
>      {
>          LOGGER.trace("ENTERING: configureCamelRoute");
>          
>          RouteBuilder routeBuilder = new RouteBuilder()   {
>              @Override
>              public void configure() throws Exception  {
>                  String inbox = "file:" + monitoredDirectory +
> "?moveFailed=.errors";
>                  inbox += "&delete=true";
>                  LOGGER.debug("inbox = " + inbox);
>
>                  from(inbox)
>                     .setHeader(Request.OPERATION, constant("create"))
>                     .setHeader(Request.DIRECTIVE, constant(directive))
>                     .setHeader(Request.CONTENT_URI, constant(""))
>                     .to("content:framework");  // our custom camel component
> "content"
>              }
>          };
>                  
>          try {
>              // Add the routes that will be built by the RouteBuilder class
> above
>              // to this CamelContext.
>              // The addRoutes() method will instantiate the RouteBuilder
> class above.
>              camelContext.addRoutes(routeBuilder);
>              camelContext.start();
>              
>              // Save the routes created by RouteBuilder so that they can be
>              // stopped and removed later if the route(s) are modified by the
>              // administrator.
>              this.routeCollection =
> routeBuilder.getRouteCollection().getRoutes();
>          }  catch (Exception e)  {
>              LOGGER.warn("Unable to configure Camel route", e);
>          }
>          
>          LOGGER.trace("EXITING: configureCamelRoute");
>      }
>
>
> Application's log output - in the "re-install" section you will see where
> Camel says it started 0 of 0 routes, when for same bundle it started 1 route
> when app was first started:
>
>
> // User fills in form to create dynamic route
>
> 13:07:56,092 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   50 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | ContentDirectoryMonitor constructor done
> 13:07:56,095 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  125 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
> 13:07:56,095 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  136 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setDirective
> 13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  125 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
> 13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  147 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setCopyIngestedFiles
> 13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  136 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setDirective
> 13:07:56,096 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   64 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: init()
> 13:07:56,096 | DEBUG | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   81 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | No routes to remove before configuring a new route
> 13:07:56,097 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  158 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | ENTERING: configureCamelRoute
> 13:07:56,097 | DEBUG | eb-f79294e88283) | ContentDirectoryMonitor          |
> onitor.ContentDirectoryMonitor$1  187 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | inbox = file:inbox?moveFailed=.errors&delete=true
> 13:07:56,161 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 2098 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Route: route2 started and consuming from:
> Endpoint[file://inbox?delete=true&moveFailed=.errors]
> 13:07:56,163 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1432 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is starting
> 13:07:56,163 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1467 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Total 1 routes, of which 1 is started.
> 13:07:56,164 | INFO  | eb-f79294e88283) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1468 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) started in 0.000
> seconds
> 13:07:56,165 | TRACE | eb-f79294e88283) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  215 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | EXITING: configureCamelRoute
> 13:07:56,165 | INFO  | eb-f79294e88283) | OsgiServiceFactoryBean           |
> r.support.OsgiServiceFactoryBean  301 | 105 - org.springframework.osgi.core
> - 1.2.1 | Publishing service under classes
> [{ddf.content.core.directorymonitor.DirectoryMonitor}]
>
> // Uninstall feature that has dynamic route
>
> 13:08:15,788 | INFO  | Timer-1          | OsgiBundleXmlApplicationContext  |
> ractOsgiBundleApplicationContext  359 | 101 - org.springframework.context -
> 3.2.3.RELEASE | Unpublishing application context OSGi service for bundle DDF
> :: Content :: Core :: Directory Monitor (content-core-directorymonitor)
> 13:08:15,789 | INFO  | Timer-1          | OsgiBundleXmlApplicationContext  |
> pport.AbstractApplicationContext 1042 | 101 - org.springframework.context -
> 3.2.3.RELEASE | Closing
> OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
> config=osgibundle:/META-INF/spring/*.xml): startup date [Thu Sep 12 13:07:23
> MST 2013]; root of context hierarchy
> 13:08:15,789 | INFO  | Timer-1          | DefaultListableBeanFactory       |
> ort.DefaultSingletonBeanRegistry  444 | 99 - org.springframework.beans -
> 3.2.3.RELEASE | Destroying singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@53ee762f:
> defining beans
> [template,consumerTemplate,camelContext:beanPostProcessor,camelContext,contentDirectoryMonitor_MSF];
> root of factory hierarchy
> 13:08:15,790 | INFO  | Timer-1          | DefaultListableBeanFactory       |
> ort.DefaultSingletonBeanRegistry  444 | 99 - org.springframework.beans -
> 3.2.3.RELEASE | Destroying singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@543cc5dd:
> defining beans
> [ddf.content.core.directorymonitor.ContentDirectoryMonitor.7d5e0227-ee53-4471-9ceb-f79294e88283];
> parent:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@53ee762f
> 13:08:15,790 | TRACE | Timer-1          | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   93 | 186 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: destroy()
> 13:08:15,791 | INFO  | Timer-1          | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1624 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is shutting down
> 13:08:15,792 | INFO  | Timer-1          | DefaultShutdownStrategy          |
> mel.impl.DefaultShutdownStrategy  165 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Starting to graceful shutdown 1 routes (timeout 300 seconds)
> 13:08:15,795 | INFO  | 3 - ShutdownTask | DefaultShutdownStrategy          |
> ultShutdownStrategy$ShutdownTask  572 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Route: route2 shutdown complete, was consuming from:
> Endpoint[file://inbox?delete=true&moveFailed=.errors]
> 13:08:15,795 | INFO  | Timer-1          | DefaultShutdownStrategy          |
> mel.impl.DefaultShutdownStrategy  213 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Graceful shutdown of 1 routes completed in 0 seconds
> 13:08:15,799 | INFO  | Timer-1          | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1695 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Uptime 19.636 seconds
> 13:08:15,799 | INFO  | Timer-1          | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1696 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is shutdown in
> 0.008 seconds
> 13:08:15,800 | INFO  | Timer-1          | ContextLoaderListener            |
> BundleApplicationContextListener   60 | 106 -
> org.springframework.osgi.extender - 1.2.1 | Application context succesfully
> closed
> (OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
> config=osgibundle:/META-INF/spring/*.xml))
>
> /////////////////// Re-install feature that has dynamic route
> /////////////////////////////////////
>
> 13:08:18,940 | INFO  | qtp798522203-258 | ultOsgiApplicationContextCreator |
> ultOsgiApplicationContextCreator   67 | 106 -
> org.springframework.osgi.extender - 1.2.1 | Discovered configurations
> {osgibundle:/META-INF/spring/*.xml} in bundle [DDF :: Content :: Core ::
> Directory Monitor (content-core-directorymonitor)]
> 13:08:18,945 | INFO  | xtenderThread-49 | OsgiBundleXmlApplicationContext  |
> pport.AbstractApplicationContext  510 | 101 - org.springframework.context -
> 3.2.3.RELEASE | Refreshing
> OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
> config=osgibundle:/META-INF/spring/*.xml): startup date [Thu Sep 12 13:08:18
> MST 2013]; root of context hierarchy
> 13:08:18,946 | INFO  | xtenderThread-49 | OsgiBundleXmlApplicationContext  |
> ractOsgiBundleApplicationContext  365 | 101 - org.springframework.context -
> 3.2.3.RELEASE | Application Context service already unpublished
> 13:08:18,947 | INFO  | xtenderThread-49 | XmlBeanDefinitionReader          |
> tory.xml.XmlBeanDefinitionReader  315 | 99 - org.springframework.beans -
> 3.2.3.RELEASE | Loading XML bean definitions from URL
> [bundleentry://338.fwk458982688/META-INF/spring/beans.xml]
> 13:08:18,979 | INFO  | xtenderThread-49 | WaiterApplicationContextExecutor |
> WaiterApplicationContextExecutor  243 | 106 -
> org.springframework.osgi.extender - 1.2.1 | No outstanding OSGi service
> dependencies, completing initialization for
> OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
> config=osgibundle:/META-INF/spring/*.xml)
> 13:08:18,982 | INFO  | xtenderThread-50 | DefaultListableBeanFactory       |
> pport.DefaultListableBeanFactory  596 | 99 - org.springframework.beans -
> 3.2.3.RELEASE | Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@59414494:
> defining beans
> [camelContext:beanPostProcessor,camelContext,contentDirectoryMonitor_MSF];
> root of factory hierarchy
> 13:08:18,991 | INFO  | xtenderThread-50 | ManagementStrategyFactory        |
> gement.ManagementStrategyFactory   43 | 170 - org.apache.camel.camel-core -
> 2.11.0 | JMX enabled.
> 13:08:18,993 | INFO  | xtenderThread-50 | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1432 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is starting
> 13:08:18,997 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   50 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | ContentDirectoryMonitor constructor done
> 13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  125 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
> 13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  136 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setDirective
> 13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  125 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setMonitoredDirectoryPath
> 13:08:18,999 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  147 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setCopyIngestedFiles
> 13:08:19,000 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  136 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: setDirective
> 13:08:19,000 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   64 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | INSIDE: init()
> 13:08:19,000 | DEBUG | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor   81 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | No routes to remove before configuring a new route
> 13:08:19,000 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  158 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | ENTERING: configureCamelRoute
> 13:08:19,001 | DEBUG | rectoryMonitor]) | ContentDirectoryMonitor          |
> onitor.ContentDirectoryMonitor$1  187 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | inbox = file:inbox?moveFailed=.errors&delete=true
> 13:08:19,013 | INFO  | xtenderThread-50 | faultManagementLifecycleStrategy |
> erListenerManagerStartupListener  872 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Load performance statistics enabled.
> 13:08:19,016 | INFO  | rectoryMonitor]) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1432 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) is starting
> 13:08:19,016 | INFO  | rectoryMonitor]) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1467 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Total 0 routes, of which 0 is started.
> 13:08:19,016 | INFO  | xtenderThread-50 | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1467 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Total 0 routes, of which 0 is started.
> 13:08:19,016 | INFO  | rectoryMonitor]) | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1468 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) started in 0.000
> seconds
> 13:08:19,017 | INFO  | xtenderThread-50 | OsgiSpringCamelContext           |
> e.camel.impl.DefaultCamelContext 1468 | 170 - org.apache.camel.camel-core -
> 2.11.0 | Apache Camel 2.11.0 (CamelContext: camelContext) started in 0.000
> seconds
> 13:08:19,018 | TRACE | rectoryMonitor]) | ContentDirectoryMonitor          |
> ymonitor.ContentDirectoryMonitor  215 | 338 - content-core-directorymonitor
> - 2.3.0.SNAPSHOT | EXITING: configureCamelRoute
> 13:08:19,018 | INFO  | xtenderThread-50 | OsgiBundleXmlApplicationContext  |
> ractOsgiBundleApplicationContext  327 | 101 - org.springframework.context -
> 3.2.3.RELEASE | Publishing application context as OSGi service with
> properties
> {org.springframework.context.service.name=content-core-directorymonitor,
> Bundle-SymbolicName=content-core-directorymonitor,
> Bundle-Version=2.3.0.SNAPSHOT}
> 13:08:19,018 | INFO  | rectoryMonitor]) | OsgiServiceFactoryBean           |
> r.support.OsgiServiceFactoryBean  301 | 105 - org.springframework.osgi.core
> - 1.2.1 | Publishing service under classes
> [{ddf.content.core.directorymonitor.DirectoryMonitor}]
> 13:08:19,019 | INFO  | xtenderThread-50 | ContextLoaderListener            |
> BundleApplicationContextListener   45 | 106 -
> org.springframework.osgi.extender - 1.2.1 | Application context successfully
> refreshed
> (OsgiBundleXmlApplicationContext(bundle=content-core-directorymonitor,
> config=osgibundle:/META-INF/spring/*.xml))
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-route-not-started-when-OSGi-bundle-it-is-in-is-uninstalled-and-then-reinstalled-tp5739282.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>