带蓝图的骆驼代理

Camel Proxy with Blueprint

我正在尝试让代理与 OSGi 中的蓝图一起正常工作(通过 Karaf 完成),并通过 gradle 构建。

我的蓝图文件(已更改名称以保护无辜者):

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">


<!-- Service proxy export for the Camel direct proxy route -->
<service id="postRoutableMessageService" interface="foo.bar.intf.RoutableMessagePoster" ref="postRoutableMessageProxy" ranking="1000">
    <service-properties>
        <entry key="protocol">
            <value type="java.lang.String">Direct</value>
        </entry>
    </service-properties>
</service>


<camelContext xmlns="http://camel.apache.org/schema/blueprint">

    <proxy id="postRoutableMessageProxy" serviceUrl="direct:postRoutableMessage" serviceInterface="foo.bar.intf.RoutableMessagePoster"/>


    <!-- Load all routes from the specified package -->
    <package>foo.bar.foo</package>

</camelContext>

</blueprint>

现在,这个蓝图文件是不可接受的。当我通过 gradle 构建到 运行 一个(非常)简单的测试时,我得到这个错误:

[ERROR] 2015-03-26 17:58:54,284 [Blueprint Extender: 1] org.apache.aries.blueprint.container.BlueprintContainerImpl doRun - 无法启动 bundle OMDDProxyRouteTest 的蓝图容器 org.osgi.service.blueprint.container.ComponentDefinitionException: 无法验证 xml

。 . .

原因:org.xml.sax.SAXParseException; cvc-complex-type.2.4.a:发现以元素 'package' 开头的无效内容。应为“{"http://camel.apache.org/schema/blueprint":template, "http://camel.apache.org/schema/blueprint":consumerTemplate, "http://camel.apache.org/schema/blueprint":proxy, "http://camel.apache.org/schema/blueprint":export, "http://camel.apache.org/schema/blueprint":errorHandler, "http://camel.apache.org/schema/blueprint":routeBuilder, "http://camel.apache.org/schema/blueprint":routeContextRef, "http://camel.apache.org/schema/blueprint":restContextRef, "http://camel.apache.org/schema/blueprint":threadPoolProfile, "http://camel.apache.org/schema/blueprint":threadPool, "http://camel.apache.org/schema/blueprint":endpoint, "http://camel.apache.org/schema/blueprint":dataFormats, "http://camel.apache.org/schema/blueprint":redeliveryPolicyProfile, "http://camel.apache.org/schema/blueprint":onException, "http://camel.apache.org/schema/blueprint":onCompletion, "http://camel.apache.org/schema/blueprint":intercept, "http://camel.apache.org/schema/blueprint":interceptFrom, "http://camel.apache.org/schema/blueprint":interceptSendToEndpoint, "http://camel.apache.org/schema/blueprint":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}'之一。

我对此非常困惑,因为它在抱怨 Camel 上下文中的标签。我在其他地方使用了完全相同的语法(只是不同的包),没有问题。

最后的'error'一切都落下了帷幕是:

java.lang.RuntimeException: 放弃等待服务(objectClass=org.apache.camel.CamelContext)

这是有道理的,因为元素在元素内部。

不过,我不知道为什么会失败。如果我删除 package 元素,一切都很好并且测试 运行s 并通过,所以它真的只是这个发臭的元素(或者它与某人交互的方式)。

欧比旺克诺比帮帮我,你是我唯一的希望(也许)。

第二个问题:我是否正确定义了代理端点及其必要的公开服务?

交换 <proxy><package> 在你的 <camelContext> 中的顺序。这些元素需要按特定顺序排列。