Access to MSSQLserver via CamelRoute in ServiceMix - apache-camel

I have an existing route in Camel with a jdbc endpoint which connects to a mssql server. That works fine.
Now i want to switch to apache servicemix to use that 'hot blueprint deployment'-feature.
The download i used: http://www.apache.org/dyn/closer.lua/servicemix/servicemix-6/6.1.0/apache-servicemix-6.1.0.zip.
The installations i did after startup of servicemix.bat:
karaf#root>feature:install camel-jetty
karaf#root>feature:install spring-jdbc
karaf#root>feature:install jdbc
karaf#root>feature:install webconsole
I want to use the jtds driver, so i also did:
karaf#root>install -s wrap:mvn:net.sourceforge.jtds/jtds/1.3.1
hoping this is correct...
Here is the blueprint-xml i copied to the deploy folder:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="myDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://theserver:1433/thedbname;user=theuser;password=thepass"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="db">
<from uri="file://c:/tmp/camel/in"/>
<setBody>
<simple>select count(*) from io</simple>
</setBody>
<to uri="jdbc:myDataSource" />
<to uri="file://c:/tmp/camel/out"/>
</route>
</camelContext>
</blueprint>
As you see for the moment i just want to count the rows in a table named 'io' when a file arrives in a folder. The result should be written to another folder.
And here the content of the logfile after the copy:
2015-12-07 13:42:15,535 | INFO | mix-6.1.0/deploy | fileinstall | 7 - org.apache.felix.fileinstall - 3.5.0 | Installing bundle mytest / 1.0.0
2015-12-07 13:42:16,417 | WARN | mix-6.1.0/deploy | DefaultTypeConverter | 199 - org.apache.camel.camel-core - 2.16.1 | Overriding type converter from: StaticMethodTypeConverter: public static org.apache.activemq.command.ActiveMQDestination org.apache.activemq.camel.converter.ActiveMQConverter.toDestination(java.lang.String) to: StaticMethodTypeConverter: public static org.apache.activemq.command.ActiveMQDestination org.apache.activemq.camel.converter.ActiveMQConverter.toDestination(java.lang.String)
2015-12-07 13:42:16,418 | WARN | mix-6.1.0/deploy | DefaultTypeConverter | 199 - org.apache.camel.camel-core - 2.16.1 | Overriding type converter from: InstanceMethodTypeConverter: public org.apache.activemq.command.ActiveMQMessage org.apache.activemq.camel.converter.ActiveMQMessageConverter.toMessage(org.apache.camel.Exchange) throws javax.jms.JMSException to: InstanceMethodTypeConverter: public org.apache.activemq.command.ActiveMQMessage org.apache.activemq.camel.converter.ActiveMQMessageConverter.toMessage(org.apache.camel.Exchange) throws javax.jms.JMSException
2015-12-07 13:42:16,418 | WARN | mix-6.1.0/deploy | DefaultTypeConverter | 199 - org.apache.camel.camel-core - 2.16.1 | Overriding type converter from: InstanceMethodTypeConverter: public org.apache.camel.Processor org.apache.activemq.camel.converter.ActiveMQMessageConverter.toProcessor(javax.jms.MessageListener) to: InstanceMethodTypeConverter: public org.apache.camel.Processor org.apache.activemq.camel.converter.ActiveMQMessageConverter.toProcessor(javax.jms.MessageListener)
2015-12-07 13:42:16,438 | INFO | mix-6.1.0/deploy | BlueprintContainerImpl | 15 - org.apache.aries.blueprint.core - 1.4.4 | Bundle mytest/1.0.0 is waiting for dependencies [(&(component=jdbc)(objectClass=org.apache.camel.spi.ComponentResolver))]
2015-12-07 13:42:16,441 | INFO | mix-6.1.0/deploy | fileinstall | 7 - org.apache.felix.fileinstall - 3.5.0 | Started bundle: blueprint:file:/C:/Program%20Files%20(x86)/apache-servicemix-6.1.0/deploy/mytest-1.0.0.xml
I think the reason is here:
Bundle mytest/1.0.0 is waiting for dependencies [(&(component=jdbc)(objectClass=org.apache.camel.spi.ComponentResolver))]
So the questions are:
What does that mean?
and how to fix that issue?
Thx for your time.

You need to install camel-jdbc as you use jdbc in your Camel route
karaf#root>feature:install camel-jdbc
And since you just copy a blueprint xml to the deploy folder, you may need to add dynamic import on its bundle id, so do a
osgi:list
And find the bundle id in the list, and then
dev:dynamic-import <ID>
And then restart it
osgi:restart <ID>
The latter can be needed to allow your blueprint xml file to load the jdbc driver.

Related

why does following bundle is in graceperiod?

I have two bundles with blueprint file having camel-activemq stuff.
like
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
..
<cm:property-placeholder id="jms.placeholder" persistent-id="com.mycompany.context">
<cm:default-properties>
<cm:property name="activemq.url" value="${activemq.url}" />
<cm:property name="activemq.user" value="${activemq.user}" />
<cm:property name="activemq.password" value="${activemq.password}" />
</cm:default-properties>
</cm:property-placeholder>
..
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
id="quartzCamelPublisher"
autoStartup="true">
<route id="failedMessagePublisher">
<from uri="vm:failedEventQueue" />
<to pattern="InOnly" uri="activemq:queue:not-success"/>
</route>
</camelContext>
<reference id="txMgr" interface="javax.transaction.TransactionManager" />
<bean id="xaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
<property name="userName" value="${activemq.user}" />
<property name="password" value="${activemq.password}" />
<property name="watchTopicAdvisories" value="false" />
</bean>
<bean id="jcaConnectionFactory" class="org.apache.activemq.jms.pool.JcaPooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="transactionManager" ref="txMgr"/>
<property name="maxConnections" value="10" />
<property name="name" value="amq" />
<property name="connectionFactory" ref="xaConnectionFactory"/>
</bean>
<bean id="jmsTxConf" class="org.apache.activemq.camel.component.ActiveMQConfiguration">
<property name="connectionFactory" ref="jcaConnectionFactory" />
<property name="requestTimeout" value="10000" />
<property name="transactionTimeout" value="30" />
<property name="transacted" value="true" />
<property name="cacheLevelName" value="CACHE_NONE" />
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="configuration" ref="jmsTxConf" />
</bean>
</blueprint>
If I use constant values in second bundle blueprint file , every thing works fine.As soon I use configuration like ${activemq.url} there, it looks it can not find it and try to get it infinite number of time. and second bundle can not resolve there.
018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from configuration with pid com.mycompany.context
2018-05-22 13:00:13,138 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,139 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,139 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,140 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from configuration with pid com.mycompany.context
2018-05-22 13:00:13,140 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,141 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,141 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,141 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from configuration with pid com.mycompany.context
2018-05-22 13:00:13,143 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,143 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,144 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,144 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from
..
..
..
If I use second configuration file which is just the duplicate config file like com.mycompany.context_1, then first bundle can not resolve with following transaction relate message.
What is the reason following bundle is in graceperiond?
karaf#root()> bundle:diag 128
ReturnContext :: My Bundle (128)
----------------------------------------------
Status: GracePeriod
Blueprint
22/5/18 12:53 PM
Missing dependencies:
(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://aries.apache.org/xmlns/transactions/v2.0.0))
Declarative Services
karaf#root()> feature:list | grep transaction
transaction-api | 1.2.0 | | Started | enterprise-4.1.2 |
transaction-manager-geronimo | 1.3.3 | | Started | enterprise-4.1.2 | Geronimo Transaction Manager
transaction-manager-narayana | 5.5.2.Final | | Uninstalled | enterprise-4.1.2 | Narayana Transaction Manager
transaction | 2.0.0 | | Started | enterprise-4.1.2 | OSGi Transaction Manager
karaf#root()>
Removing all default entry from the blueprint file has fixed the issue.
And using property from cofig file is also working.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint ...
<cm:property-placeholder id="jms.placeholder" persistent-id="com.mycompany.context">
<cm:default-properties>
</cm:default-properties>
</cm:property-placeholder>
....
<bean id="xaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
<property name="userName" value="${activemq.user}" />
<property name="password" value="${activemq.password}" />
<property name="watchTopicAdvisories" value="false" />
</bean>
...
</blueprint>

Error occurred during camel start because of circular dependency

On placing a bundle (using camel) on Karaf I am seeing the below exception. The below exception comes only when the bundle is started. After that everything works fine. The exeception does not seem to effect our functionality. The issue is coming on both camel 2.16.1 (deployed on servicemix 6.1.0) and camel 2.16.3 (deployed on servicemix 7.0.0M2).
My blueprint is split into three files. A simplified version of them are shown below:-
blueprint.xml placed here.
productBeans.xml placed here.
camelContext.xml placed here.
Can some please let me know why is this exception coming during bundle start? It appears from the below stack-trace that it is because of some circular dependency. How can I get around this?
2016-07-04 11:29:37,497 | ERROR | mix-6.1.0/deploy | BlueprintCamelContext | 143 - org.apache.camel.camel-blueprint - 2.16.1 | {{bundle.id,143}{bundle.name,org.apache.camel.camel-blueprint}{bundle.version,2.16.1}} | Error occurred during starting Camel: CamelContext(camel-1) due Failed to create route orchestrator-service-route at: >>> process[ref:jsonRPCProcessor] <<< in route: Route(orchestrator-service-route)[[From[jetty:http://0.0.0.0... because of Cannot lookup: jsonRPCProcessor from registry: org.apache.camel.blueprint.BlueprintContainerRegistry#7b081b97 with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
org.apache.camel.FailedToCreateRouteException: Failed to create route orchestrator-service-route at: >>> process[ref:jsonRPCProcessor] <<< in route: Route(orchestrator-service-route)[[From[jetty:http://0.0.0.0... because of Cannot lookup: jsonRPCProcessor from registry: org.apache.camel.blueprint.BlueprintContainerRegistry#7b081b97 with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:947)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3258)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2981)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777)
at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:180)[143:org.apache.camel.camel-blueprint:2.16.1]
at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:212)[143:org.apache.camel.camel-blueprint:2.16.1]
at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:150)[143:org.apache.camel.camel-blueprint:2.16.1]
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4419)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.registerService(Felix.java:3423)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:352)
at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:100)[143:org.apache.camel.camel-blueprint:2.16.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_77]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.camel.blueprint.CamelProducerTemplateFactoryBean.getCamelContextWithId(CamelProducerTemplateFactoryBean.java:49)
at org.apache.camel.core.xml.AbstractCamelFactoryBean.afterPropertiesSet(AbstractCamelFactoryBean.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_77]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:280)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:931)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:905)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:886)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:682)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:377)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:294)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:263)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:253)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[9:org.apache.aries.util:1.1.1]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[9:org.apache.aries.util:1.1.1]
at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2092)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:518)[20:org.apache.karaf.features.core:3.0.5]
at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:476)[20:org.apache.karaf.features.core:3.0.5]
at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:417)[20:org.apache.karaf.features.core:3.0.5]
at Proxy1be55f4b_f63a_43b3_883f_77a48747d768.installFeature(Unknown Source)[:]
at Proxy1fa9f34f_3928_4828_8542_9d785df163bd.installFeature(Unknown Source)[:]
at org.apache.karaf.kar.internal.KarServiceImpl.installFeatures(KarServiceImpl.java:215)[160:org.apache.karaf.kar.core:3.0.5]
at org.apache.karaf.kar.internal.KarServiceImpl.install(KarServiceImpl.java:96)[160:org.apache.karaf.kar.core:3.0.5]
at org.apache.karaf.kar.internal.KarServiceImpl.install(KarServiceImpl.java:84)[160:org.apache.karaf.kar.core:3.0.5]
at Proxya6f8b1d5_e9a2_4e1b_a105_1552c365b9de.install(Unknown Source)[:]
at Proxye3575645_14c4_4cf9_8d71_16cd6e82b1a0.install(Unknown Source)[:]
at org.apache.karaf.deployer.kar.KarArtifactInstaller.install(KarArtifactInstaller.java:50)[162:org.apache.karaf.deployer.kar:3.0.5]
at Proxy6b7a1495_9239_4ff3_b9ed_1fd58a17750b.install(Unknown Source)[:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:931)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:865)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:482)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[7:org.apache.felix.fileinstall:3.5.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[7:org.apache.felix.fileinstall:3.5.0]
Caused by: org.apache.camel.NoSuchBeanException: Cannot lookup: jsonRPCProcessor from registry: org.apache.camel.blueprint.BlueprintContainerRegistry#7b081b97 with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:62)
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63)
at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:137)
at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:157)
at org.apache.camel.impl.DefaultRouteContext.mandatoryLookup(DefaultRouteContext.java:151)
at org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:95)
at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:534)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:495)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)
... 105 more
Caused by: org.apache.aries.blueprint.di.CircularDependencyException: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']]
at org.apache.aries.blueprint.container.BlueprintRepository.push(BlueprintRepository.java:343)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:71)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)[15:org.apache.aries.blueprint.core:1.4.4]
at org.apache.camel.blueprint.BlueprintContainerRegistry.lookupByNameAndType(BlueprintContainerRegistry.java:54)
at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:56)
... 114 more
EDIT - It seems the error is because the jsonRPCProcessor is using myTemplate as shown below:-
<bean id="jsonRPCProcessor" class="com.j1.orchestratorservice.basecomponent.processor.JSONRPCProcessor">
<argument ref="myTemplate" />
<argument>
<map>
<!-- Product End Points -->
<entry key="Product.createProducts" value-ref="createProductsWFInfo" />
</map>
</argument>
<argument ref="exceptionHandler" />
</bean>
whereas myTemplate is defined in camelContext which in turn is using jsonRPCProcessor as shown below:-
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
useMDCLogging="true">
<template id="myTemplate" />
<route id="orchestrator-service-route">
<from uri="jetty:http://0.0.0.0:8888/orchestratorservice" />
<process ref="jsonRPCProcessor" />
</route>
<route id="file-upload-service-route">
<from
uri="jetty:http://0.0.0.0:8889/fileuploadservice?enableMultipartFilter=true" />
<process ref="fileUploadProcessor" />
</route>
...
</camelContext>
I have tried to set the producer in my custom Processor as mentioned in this link. Can someone suggest me some other way of setting the producer in my custom jsonRPCProcessor so that it does not lead to any circular dependency?
I am able to get around this by removing myTemplate from jsonRPCProcesor and fileUploadProcessor. Now my jsonRPCProcessor look something like below:-
<bean id="jsonRPCProcessor" class="com.j1.orchestratorservice.basecomponent.processor.JSONRPCProcessor">
<argument>
<map>
<entry key="Product.createProducts" value-ref="createProductsWFInfo" />
</map>
</argument>
<argument ref="exceptionHandler" />
</bean>
Annotated the ProducerTemplate(in the base class) in my code with #EndPointInject. Something like below:-
#EndpointInject
protected ProducerTemplate myTemplate;

Fabric-karaf, Apache Camel, fabric-camel: "Component is not started"

I have a problem with fabric-camel component.
It detects my camel endpoints from blueprint:
2014-10-02 15:27:43,598 | INFO | 26c-351-thread-2 | FabricPublisherEndpoint | 204 - io.fabric8.fabric-camel - 1.1.0.CR5 | Child: jetty:https://127.0.0.1:1221/https/incontrol?matchOnUriPrefix=true
2014-10-02 15:27:43,598 | INFO | 26c-351-thread-2 | FabricPublisherEndpoint | 204 - io.fabric8.fabric-camel - 1.1.0.CR5 | Consumer: jetty:https://127.0.0.1:1221/https/incontrol?matchOnUriPrefix=true
But then I get "Caused by: java.lang.IllegalStateException: Component is not started"
2014-10-02 15:27:43,602 | ERROR | 26c-351-thread-2 | BlueprintContainerImpl | 197 - org.apache.aries.blueprint.core - 1.4.0 | Unable to start blueprint container for bundle pl.com.xxxxxx.esb.esb-incontrol-proxy
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean .camelBlueprint.factory.inControlProxyContext
...
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: fabric://incontrol:jetty:https://127.0.0.1:1221/https/incontrol?matchOnUriPrefix=true due to: Component is not started
...
Caused by: java.lang.IllegalStateException: Component is not started
at io.fabric8.camel.ZKComponentSupport.createGroup(ZKComponentSupport.java:53)
More detailed stacktrace http://pastebin.com/BFrPBarp
My blueprint.xml (relevant parts):
<!-- Boundary beans -->
<bean id="httpsRouteBuilder" class="pl.com.xxxxxxx.camel.builder.HttpsRouteBuilder">
...
<property name="incomingUri" value="fabric:incontrol:jetty:${endpoint.https.incoming.url}?matchOnUriPrefix=true"/>
<property name="outgoingUri" value="${endpoint.https.outgoing.url}?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
...
</bean>
...
<camelContext id="inControlProxyContext" trace="false" streamCache="true"
xmlns="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint-2.10.0.xsd">
...
<routeBuilder ref="httpsRouteBuilder"/>
...
</camelContext>
My pom.xml (relevant parts):
<!-- Fabric -->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>fabric-camel</artifactId>
<scope>provided</scope>
</dependency>
I'll try to enable debug logging and see what else I can find. Unfortunately I still don't understand the underlying issue: why the component was not started?
Version info:
Karaf: 2.3.0.redhat-610379
Fabric: 1.1.0.CR5
You can try to enforce the component to be manually instantiated and started before the route is started: Try something like this:
<endpoint xmlns="http://camel.apache.org/schema/blueprint" id="fakeFabricEndpoint" uri="fabric:fake:jetty:${endpoint.https.incoming.url}?matchOnUriPrefix=true"/>

"Graceful shutdown of routes completed in 0 seconds" then "Shutting down while there are still 1 in flight exchanges"

I have this :
15:20:06 | INFO | aultShutdownStrategy | mel.impl.DefaultShutdownStrategy 73 | Starting to graceful shutdown routes (timeout 300 seconds)
15:20:06 | INFO | aultShutdownStrategy | mel.impl.DefaultShutdownStrategy 106 | Graceful shutdown of routes completed in 0 seconds
15:20:06 | WARN | ltInflightRepository | l.impl.DefaultInflightRepository 91 | Shutting down while there are still 1 in flight exchanges.
I thought the graceful shutdown would wait for this in flight exchange to land!
Why does it say "shutdown of routes completed in 0 seconds"?
Could it be related to the Thread.sleep(30000); I wrote in a processor in the route where the exchange is still inflight?
EDIT :
I have this config into applicationContext :
<bean id="MainRouteBuilder" class="something.router2.MainRoute" init-method="init">
<property name="ruleService" >
<osgi:reference interface="something.router2.service.RuleService" />
</property>
<property name="controlInbox" value="${router.controlInbox}" />
<property name="errorBox" value="${router.errorBox}" />
<property name="rulesCamelContext" ref="secondCamelContext" />
</bean>
<!-- Camel -->
<camelContext xmlns="http://camel.apache.org/schema/spring" id="myCamelContext">
<routeBuilder ref="MainRouteBuilder"/>
</camelContext>
<camelContext xmlns="http://camel.apache.org/schema/spring" id="secondCamelContext">
</camelContext>
I try to stop "secondCamelContext" into a route using "myCamelContext".
How do you shutdown the application?
If you trigger a shutdown from a route then see this FAQ: http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html how to do this correctly. If doing this wrong then you may have the situation above with 1 inflight message stuck in the registry when you shutdown.

Routing queues with Service Mix

I'm trying to configure Apache ServiceMix to implement the network topology below:
I'm very new in Service Mix, Camel, ActiveMq etc. stuff and the main issue I'm trying to solve is to route messages from Output queue of DC1.ActiveMqBroker to the Input queue of DC2.ActiveMqBroker.
I'm sure this should be easy. Could someone point me to the good article or write rough snippet of configuration (in Spring/Blueprint, doesn't matter)?
UPDATE:
Sorry for long text but I don't see other way to tell my problem.
My sample configuration:
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="dc2" dataDirectory="${karaf.data}/activemq/dc2" useShutdownHook="false">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue="input" producerFlowControl="true" memoryLimit="1mb"/>
<policyEntry queue="output" producerFlowControl="true" memoryLimit="1mb"/>
</policyEntries>
</policyMap>
</destinationPolicy>
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<persistenceAdapter>
<kahaDB directory="${karaf.data}/activemq/dc2/kahadb"/>
</persistenceAdapter>
<transportConnectors>
<transportConnector name="openwire" uri="tcp://localhost:61619"/>
</transportConnectors>
</broker>
<bean id="dc1activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61619" />
</bean>
<bean id="dc2activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61618" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="dc1activemq:queue:output"/>
<log message="Took message from dc1 to dc2"/>
<to uri="dc2activemq:queue:input"/>
</route>
</camelContext>
And I constantly get following error:
08:06:40,739 | INFO | rint Extender: 3 | Activator | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Found 1 #Converter classes to load
08:06:40,740 | INFO | rint Extender: 3 | Activator | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Found 1 #Converter classes to load
08:06:40,741 | INFO | rint Extender: 3 | Activator | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Found 1 #Converter classes to load
08:06:40,741 | INFO | rint Extender: 3 | Activator | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Found 2 #Converter classes to load
08:06:40,749 | INFO | rint Extender: 3 | Activator | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Found 13 #Converter classes to load
08:06:40,754 | INFO | rint Extender: 3 | BlueprintCamelContext | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | JMX enabled. Using ManagedManagementStrategy.
08:06:40,758 | INFO | rint Extender: 3 | BlueprintCamelContext | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0 (CamelContext: 211-camel-165) is starting
08:06:42,364 | INFO | rint Extender: 3 | BlueprintCamelContext | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Route: route55 started and consuming from: Endpoint[dc1activemq://queue:output]
08:06:42,364 | INFO | rint Extender: 3 | BlueprintCamelContext | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Total 1 routes, of which 1 is started.
08:06:42,365 | INFO | rint Extender: 3 | BlueprintCamelContext | ? ? | 68 - or
g.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0 (CamelContext: 211-camel-165) started in 1.606 seconds
08:06:48,379 | WARN | tenerContainer-1 | DefaultMessageListenerContainer | ? ? | 77 - or
g.springframework.jms - 3.0.5.RELEASE | Could not refresh JMS Connection for destination 'output' - retrying in 5000 ms. Cau
se: Could not connect to broker URL: tcp://localhost:61619. Reason: java.net.ConnectException: Connection refused: connect
08:06:54,381 | WARN | tenerContainer-1 | DefaultMessageListenerContainer | ? ? | 77 - or
g.springframework.jms - 3.0.5.RELEASE | Could not refresh JMS Connection for destination 'output' - retrying in 5000 ms. Cau
se: Could not connect to broker URL: tcp://localhost:61619. Reason: java.net.ConnectException: Connection refused: connect
I'm making an assumption that you've got a handle on how Camel is started up in ServiceMix and have a few (at least) proof-of-concept routes going.. if not, start there. Also assuming that you know the URLs of the 2 message brokers, and that they're set up already.
Given that, one solution is to register two ActiveMQComponents:
<bean id="dc1activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://DC1BrokerLocation:12345" />
</bean>
<bean id="dc2activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://DC2BrokerLocation:12345" />
</bean>
And then in your camel context:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="dc1activemq:queue:whateverTheOutQueueIsCalled"/>
<log message="Took message from dc1 to dc2"/>
<to uri="dc2activemq:queue:whateverTheInQueueIsCalled"/>
</route>
<route>
<from uri="dc2activemq:queue:whateverTheOutQueueIsCalled"/>
<log message="Took message from dc2 to dc1"/>
<to uri="dc1activemq:queue:whateverTheInQueueIsCalled"/>
</route>
<camelContext>

Resources