使用蓝图作为 Apache Camel DSL 来描述 IBM Liberty 中的路由

Using blueprint as the Apache Camel DSL to describe routes in IBM Liberty

我的目标是使用 OSGi 在 IBM Liberty 应用程序服务器下获取 Camel 运行,并能够在蓝图中描述 DSL(领域特定语言)路由。我正在取得进展,现在有一个安装了 Camel 并将其配置为 OSGi 包的 Liberty 环境。当我将 Java DSL Camel 应用程序编写为 OSGi 包时,一切都如我所愿。

我的最后一步是能够在蓝图中描述我的骆驼路线。为此,我创建了一个新的 OSGi 包并定义了一个 blueprint.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"
    xmlns:camelBlueprint="http://camel.apache.org/schema/blueprint"
    xsi:schemaLocation="http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint-2.14.1.xsd">

    <camelBlueprint:camelContext>
        <camelBlueprint:route>
            <camelBlueprint:from uri="file:c:/temp/in"/>
            <camelBlueprint:to uri="file:c:/temp/out"/>
        </camelBlueprint:route>
    </camelBlueprint:camelContext>

</blueprint>

当我尝试部署此 OSGi 包时,IBM Liberty OSGi 框架无法部署应用程序并出现以下错误:

[3/2/15 0:42:38:796 CST] 00000035 com.ibm.ws.app.manager.esa.internal.DeploySubsystemAction
A CWWKZ0403E: A management exception was generated when trying to install the application Camel1 into an OSGi framework.  The error text from the OSGi framework is:
Resource does not exist: org.apache.aries.subsystem.core.archive.SubsystemContentRequirement: 
namespace=osgi.identity, attributes={}, directives={filter=(&(osgi.identity=OSGITest1)(type=osgi.bundle)(version>=1.0.0))}, resource=org.apache.aries.subsystem.core.internal.SubsystemResource@7bc2d3bc

不幸的是,这就是我现在陷入困境的地方。我相信 IBM Liberty 使用 Equinox 作为 OSGi 平台而不是 Karaf 但阅读 Camel Blueprint 文档我似乎明白 Apache Aries 是必需的(Liberty 提供和使用)并且 Karaf 不是依赖项。

我的测试包 MANIFEST.MF 是:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: OSGITest1
Bundle-SymbolicName: OSGITest1
Bundle-Version: 1.0.0.qualifier
Bundle-Blueprint: OSGI-INF/blueprint/*.xml
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: kolban.osgitest
Import-Package: org.apache.camel;version="2.14.1",
 org.apache.camel.blueprint;version="2.14.1"

如果解析器看不到包,或者包有问题(通常是蓝图),就会出现此消息。如果删除蓝图时包解析正常,那么您需要查看蓝图中可能存在的问题。如果是这种情况,我怀疑您没有在运行时启用 Camel 蓝图命名空间处理程序。

希望对您有所帮助。

问候,格雷厄姆。