【问题标题】:Camel Proxy with Blueprint带蓝图的骆驼代理
【发布时间】:2015-05-31 03:13:36
【问题描述】:

我正在尝试让代理在 OSGi 中与 Blueprint 一起正常工作(通过 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 构建以运行(非常)简单的测试时,出现此错误:

[错误] 2015-03-26 17:58:54,284 [蓝图扩展器:1] org.apache.aries.blueprint.container.BlueprintContainerImpl doRun - 无法启动捆绑包 OMDDProxyRouteTest 的蓝图容器 org.osgi.service.blueprint.container.ComponentDefinitionException: 无法验证 xml

。 . .

原因:org.xml.sax.SAXParseException; cvc-complex-type.2.4.a:发现以元素“包”开头的无效内容。 '{"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, "@ 987654339@":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' 是预期的。

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

最终导致一切崩溃的最后一个“错误”是:

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

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

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

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

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

【问题讨论】:

    标签: java proxy apache-camel karaf blueprint-osgi


    【解决方案1】:

    在您的&lt;camelContext&gt; 中交换&lt;proxy&gt;&lt;package&gt; 的顺序。这些元素需要按特定顺序排列。

    【讨论】:

    • 你能链接指定那种东西的规范/文档吗?
    • XML 文件具有指示顺序的 XSD 架构。现代 Java 编辑器可以为您验证这一点。架构文件也在线:camel.apache.org/schema/blueprint
    • 我正在尝试使用多个蓝图文件编写一个大型 OSGi 项目,但遇到了困难,但找不到可以很好地说明某些功能的有用教程,有什么想法吗?我正在尝试使用许多代理,这些代理引用分布在多个蓝图文件中的 bean。
    猜你喜欢
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-27
    • 2020-01-11
    • 1970-01-01
    相关资源
    最近更新 更多