Search code examples
apache-camelapache-karafapache-servicemix

Access to MSSQLserver via CamelRoute in ServiceMix


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.


Solution

  • 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.