2016-09-26 38 views
1

我试图评估JBoss Fuse作为一个集成平台,并且我有以下有关部署的问题。如何在JBoss Fuse 6.2.1中正确管理功能配置部署?

我正在尝试设置结构并使用配置文件,更具体地说,用于骆驼/蓝图组件部署的功能存储库。 我在外部化组件配置时遇到以下问题:当我更新配置文件工件的快照时,配置更改未由容器拾取。

此外,当我从容器中完全删除配置文件时,PID配置文件停留在服务器的etc /文件夹中。

另外还有一个额外的问题,在加载config pid文件之前激活骆驼束,导致aries蓝图异常,并且我必须手动额外刷新osgi bundle。

这里是功能库文件中的样子:

<?xml version="1.0" encoding="UTF-8"?> 
<features name="fuse-poc"> 
    <feature name="fuse-poc-common" version="${project.version}"> 
     <bundle>mvn:com.myorg.fuse/common/${project.version}</bundle> 
    </feature> 
    <feature name="fuse-poc-camel" version="${project.version}"> 
     <feature>fuse-poc-common</feature> 
     <config name="com.myorg.fuse.poc.camel"> 
      test.value=ENC(5XdDgfKwwhMTmbo1z874eQ==) 
     </config> 
     <bundle>mvn:com.myorg.fuse/fuse-poc-camel/${project.version}   </bundle> 
    </feature> 
    <feature name="fuse-poc-activemq" version="${project.version}"> 
     <feature>fuse-poc-common</feature> 
     <configfile finalname="etc/com.myorg.fuse.poc.jms.cfg"> 
      mvn:com.myorg.fuse/feature/${project.version}/cfg/dev 
     </configfile> 
     <bundle>mvn:com.myorg.fuse/fuse-poc-camel- activemq/${project.version}</bundle> 
    </feature> 
</features> 

这些项目本身使用的ActiveMQ和CM具有记录和基本路线一个有航线一个简单的骆驼原型项目:财产占位符blueprint.xml

这里是行家相应构建部分:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
    <groupId>com.myorg.fuse</groupId> 
    <artifactId>fuse-poc-parent</artifactId> 
    <version>1.0.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>feature</artifactId> 
    <packaging>pom</packaging> 


    <name>FUSE PoC Feature Repository</name> 
    <build> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
       <filtering>true</filtering> 
      </resource> 
     </resources> 
    <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-resources-plugin</artifactId> 
       <version>2.6</version> 
       <executions> 
        <execution> 
         <id>filter</id> 
         <phase>generate-resources</phase> 
         <goals> 
          <goal>resources</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
    <plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>build-helper-maven-plugin</artifactId> 
    <version>1.10</version> 
    <executions> 
    <execution> 
    <id>attach-artifacts</id> 
    <phase>package</phase> 
    <goals> 
    <goal>attach-artifact</goal> 
    </goals> 
    <configuration> 
    <artifacts> 
    <artifact> 
    <file>target/classes/fuse-poc.xml</file> 
    <type>xml</type> 
    <classifier>features</classifier> 
    </artifact> 
           <artifact> 
            <file>src/main/resources/env/dev/com.myorg.fuse.poc.jms.cfg</file> 
            <type>cfg</type> 
            <classifier>dev</classifier> 
           </artifact> 
    </artifacts> 
    </configuration> 
    </execution> 
    </executions> 
    </plugin> 
    </plugins> 
    </build> 
</project> 

下面是我用来部署个的命令Ë功能:

面料:版本创建1.1 面料:配置文件创建--parent的jboss-熔断器熔断全-POC 面料:配置文件编辑--repository MVN:com.myorg.fuse /功能/1.0.0-SNAPSHOT/xml/features熔丝POC 1.1

织物:轮廓编辑--feature熔断器POC-骆驼熔断器POC 1.1 织物:轮廓编辑--feature熔断器POC-ActiveMQ的保险丝-poc 1.1

fabric:container-upgrade 1.1 root fabric:container-add-profile root fuse-poc

我手动完成osgi:refresh <bundle id>后,它开始正常工作。

织物:容器移除简档的根熔丝POC

所有配置PID项留在配置,并且也滞留安装了所有OSGi包。我如何正确地取消部署工件以便容器清洁并且可以部署同一工件的更新版本而不产生副作用?

我怀疑我在做一些概念上的错误,因为最终上述问题导致了以下问题:如果我添加属性到要素中的要素或.cfg文件并再次使用maven安装项目,并且然后执行container-remove-profile,profile-refresh和container-add-profile,配置根本不会改变。它只能正确地重新部署,如果我手动在控制台上对我的pid执行config:delete命令。

回答

1

因此,我终于有时间挖掘源代码并交叉引用karaf,fabric和jboss文档。
下面是如何工作的:

  • 通过特征储存库系统负责装载/卸载束的代码位于织物剂1.2.0.redhat-621084.jar
  • 值得注意的是,类io.fabric8.agent.service.FeatureConfigInstaller负责配置条目,并且io.fabric8.agent.service.Agent类正在进行整体部署
  • 根本没有代码可以卸载配置文件/删除配置条目。这使得使用SNAPSHOT进行开发很麻烦
  • 但是,在<configfile>元素上可以指定一个有用的'覆盖'属性 - 如果设置为true,配置PID文件将在部署时被覆盖我想为本地开发做些什么
  • 对于<config>元素,有一个未记录的'append'属性,当它设置为true时,应该将新条目附加到配置中。然而,它被疯狂地窃听 - 事实证明,它也会在尝试追加时删除所有定义的以前存在的属性。结论 - 使用<configfile>功能代替
  • 此外,对于外部化环境配置,我已经得出结论,最简单的方法是通过不同的maven构建配置文件从同一文件生成多个功能xml描述符。项目文件因此是这样的:

的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <groupId>com.myorg.fuse</groupId> 
     <artifactId>fuse-poc-parent</artifactId> 
     <version>1.0.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>feature</artifactId> 
    <packaging>pom</packaging> 


    <name>FUSE PoC Feature Repository</name> 

    <properties> 
     <build.environment>dev</build.environment> 
    </properties> 

    <build> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
       <filtering>true</filtering> 
      </resource> 
     </resources> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-resources-plugin</artifactId> 
       <version>2.6</version> 
       <executions> 
        <execution> 
         <id>filter</id> 
         <phase>generate-resources</phase> 
         <goals> 
          <goal>resources</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.10</version> 
       <executions> 
        <execution> 
         <id>attach-artifacts</id> 
         <phase>package</phase> 
         <goals> 
          <goal>attach-artifact</goal> 
         </goals> 
         <configuration> 
          <artifacts> 
           <artifact> 
            <file>target/classes/fuse-poc.xml</file> 
            <type>xml</type> 
            <classifier>features-${build.environment}</classifier> 
           </artifact> 
           <artifact> 
            <file>src/main/resources/env/${build.environment}/com.myorg.fuse.poc.cfg</file> 
            <type>cfg</type> 
            <classifier>${build.environment}</classifier> 
           </artifact> 
          </artifacts> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <profiles> 
     <profile> 
      <id>local</id> 
      <properties> 
       <build.environment>local-dev</build.environment> 
      </properties> 
     </profile> 
     <profile> 
      <id>dev</id> 
      <properties> 
       <build.environment>dev</build.environment> 
      </properties> 
     </profile>  
     <profile> 
      <id>uat</id> 
      <properties> 
       <build.environment>uat</build.environment> 
      </properties> 
     </profile> 
     <profile> 
      <id>prod</id> 
      <properties> 
       <build.environment>prod</build.environment> 
      </properties> 
     </profile>  
    </profiles> 
</project> 

feature.xml的:

<?xml version="1.0" encoding="UTF-8"?> 
<features name="fuse-poc"> 
    <feature name="fuse-poc-common" version="${project.version}"> 
     <bundle>mvn:com.myorg.fuse/common/${project.version}</bundle> 
    </feature> 
    <feature name="fuse-poc-camel" version="${project.version}"> 
     <feature>fuse-poc-common</feature> 
     <configfile finalname="etc/com.myorg.fuse.poc.cfg" override="true"> 
      mvn:com.myorg.fuse/feature/${project.version}/cfg/${build.environment} 
     </configfile> 
     <bundle>mvn:com.myorg.fuse/fuse-poc-camel/${project.version}</bundle> 
    </feature> 
</features> 

这种方式部署创建配置文件时,你可以直接指定环境功能:

fabric:profile-create --parent jboss-fuse-full fuse-poc fabric:profile-edit --repository mvn:com.myorg.fuse/feature/1.0.0-SNAPSHOT/xml/features-local-dev fuse-poc 

备注设置构建集成工具以构建除“local-dev”以外的所有配置文件的功能模块,因为该配置需要由本地开发人员使用,并且不应从中央存储库下载

最后,一旦我解决了配置处理问题并且捆绑包开始正确部署,平台也开始在从容器中移除配置文件时正确取消部署捆绑包。我怀疑在原始部署以失败告终时,卸载软件包时会出现一些问题

相关问题