在 ServiceMix 中通过 CamelRoute 访问 MSSQLserver

Access to MSSQLserver via CamelRoute in ServiceMix

我在 Camel 中有一个现有路由,带有一个连接到 mssql 服务器的 jdbc 端点。效果不错。

现在我想切换到 apache servicemix 以使用该 'hot blueprint deployment'-feature。

我使用的下载: http://www.apache.org/dyn/closer.lua/servicemix/servicemix-6/6.1.0/apache-servicemix-6.1.0.zip.

servicemix.bat启动后的安装:

我想用jtds驱动,所以我也用了:

希望这是正确的...

这是我复制到部署文件夹的蓝图-xml:

<?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>

如您目前所见,当文件到达文件夹时,我只想计算名为 'io' 的 table 中的行数。结果应该写入另一个文件夹。

复制后日志文件的内容如下:

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

我觉得原因在这里:

Bundle mytest/1.0.0 is waiting for dependencies [(&(component=jdbc)(objectClass=org.apache.camel.spi.ComponentResolver))]

所以问题是:

谢谢你的时间。

您需要安装 camel-jdbc,因为您在 Camel 路由中使用 jdbc

karaf@root>feature:install camel-jdbc

并且由于您只是将蓝图 xml 复制到部署文件夹,您可能需要在其包 ID 上添加动态导入,因此

osgi:list

并在列表中找到bundle id,然后

dev:dynamic-import <ID>

然后重启

osgi:restart <ID>

后者可能需要让您的蓝图 xml 文件加载 jdbc 驱动程序。