在ServiceMix的deploy文件夹中将Camel路由部署为XML时,设置捆绑包版本和启动级别

w46czmvw  于 2023-03-18  发布在  Apache
关注(0)|答案(2)|浏览(82)

当在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的起始级别。

llmtgqce

llmtgqce1#

这可能不是最方便的解决方案,但是:
您可以使用这种结构创建Maven项目

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

必须:

<packaging>bundle</packaging>

在pom.xml中,您可以设置所有需要的bundle参数:

<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的级别是启动的,您可以在www.example.com中定义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>
rsaldnfx

rsaldnfx2#

我知道你说的是ServiceMix,这只设置了版本,而不是入门级,但这对我在卡拉夫工作:

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

<manifest xmlns="http://karaf.apache.org/xmlns/deployer/blueprint/v1.0.0">
Bundle-SymbolicName My Cool Bundle
Bundle-Version: 1.2.3
</manifest>

https://svn.apache.org/repos/asf/karaf/site/production/manual/latest/deployers.html#_blueprint_deployer

相关问题