微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在ServiceMix的deploy文件夹中将camel路由部署为XML时设置bundle版本和启动级别

如何解决在ServiceMix的deploy文件夹中将camel路由部署为XML时设置bundle版本和启动级别

在ServiceMix的“deploy”文件夹中部署bundle时,我想知道是否可以在蓝图XML中设置bundle版本。

Camel 路线示例(蓝图 xml):

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xsi:schemaLocation="
       http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
       http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
       http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">


    <cm:property-placeholder persistent-id="my.deploy.route" update-strategy="reload">
        <cm:default-properties>
            <cm:property name="amq.url" value="tcp://my-amq-host:61616?jms.watchTopicAdvisories=false" />
            <cm:property name="tracer.enable" value="false" />
        </cm:default-properties>
    </cm:property-placeholder>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <onException uSEOriginalMessage="true">
            <exception>java.lang.Exception</exception>
            <handled>
                <constant>true</constant>
            </handled>
            <to uri="activemq:queue:SYNCHRO.DLQ" />
        </onException>

        <route id="route-countries">
            <from uri="activemq:queue:SYS.soURCE.COUNTRY" />
            <to uri="activemq:queue:OTHER.DESTINATION.COUNTRY" />
        </route>

    </camelContext>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="brokerURL" value="${amq.url}" />
    </bean>
</blueprint>

部署后,smx 控制台中的列表显示

[1233] [Active     ] [Created     ] [       ] [   80] country-route-dev.xml (0.0.0)

我想知道是否也可以更改认为 80 的起始级别。

解决方法

这可能不是最方便的解决方案,但是:

你可以用这样的结构创建一个Maven项目

src
- main
- - resources
- - - OSGI-INF 
- - - - blueprint
- - - - -  blueprint.xml
pom.xml

必然:

<packaging>bundle</packaging>

在 pom.xml 中你可以设置你需要的所有包参数:

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Description>${project.description}</Bundle-Description>
                    <Bundle-Version>1.0.0</Bundle-Version>
                    <Import-Package>*</Import-Package>
                </instructions>
            </configuration>
        </plugin>

构建您的包并获取用于部署的 jar 文件

bundle的级别,可以在config.properties中定义

#
# Definition of the default bundle start level
#
org.osgi.framework.startlevel.beginning=100
karaf.startlevel.bundle=80

您还可以为您的捆绑包创建功能并重置开始级别:

  <feature name="my-project" version="1.0.0">
    <bundle start-level="80" start="false">mvn:com.mycompany.myproject/myproject-dao</bundle>
    <bundle start-level="85" start="false">mvn:com.mycompany.myproject/myproject-service</bundle>
  </feature>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?