Skip to main content

Red Hat Fuse/A-MQ - Tips, Maven pom.xml for developing a FUSE Project


Red Hat JBoss A-MQ is a high performance and flexible messaging platform.

Red Hat JBoss Fuse is an open source Enterprise Service Bus (ESB) with an elastic footprint that supports integration beyond the data center. With Fuse, you will have Apache Camel to provide a full-featured, easy-to-use and intuitive framework for quicker integration solutions. The components supported in Fuse 6.1 are listed here!

To create connector to A-MQ or developing Camel  integration program in Fuse, we often use Maven to manage our project builds. But with many version of dependencies, how do I which one is right? Surprisingly not many people know about this, so I am going to put this in my blog. In case  the next time you are going to develop a Fuse or A-MQ project it will save a hell lot of time to resolve conflict package versions, finding the right version.

After creating your maven project through either loading archetype or a blank pom, there are few parts of in POM that needs to be changed, to make life easier. We want to set the right version of artifacts dependency used in FUSE or AMQ 6.1. So most important part is to use "dependencyManagement" let it automatically load the correct versions of Fuse & A-MQ for different artifacts.

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.fuse.bom</groupId>
                <artifactId>jboss-fuse-parent</artifactId>
                <version>${jboss.fuse.bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

For 6.1 of Fuse, please add the version 6.1.0.redhat-379 in the "properties" tag

    <properties>
        <jboss.fuse.bom.version>6.1.0.redhat-379</jboss.fuse.bom.version>
    </properties>

So there is no need to add the version for the artifacts that are in FUSE and A-MQ.

For example :
    <dependency>
         <groupId>org.apache.camel</groupId>
         <artifactId>camel-core</artifactId>
    </dependency>

The second part is to make it easier for you to deploy your project on to Fabric, so we can utilize the functionality of Fabric.

First add the username and password of your Fuse conole in the ~/.m/setting.xml. Note you can define different set of ID and password for different environment.

    <servers>
      <server>
        <id>fabric8.upload.repo</id>
        <username>Username4Default</username>
        <password>Password4Default</password>
      </server>
      <server>
        <id>fabric8.demo.repo</id>
        <username>Username4DEMO</username>
        <password>Password4DEMO</password>
      </server>
    </servers>

Add the Maven Plugin, with configuration

    <plugins>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-maven-plugin</artifactId>
        <configuration>
          <profile>${fabric8.profile}</profile>
          <serverId>${fabric8. serverId}</serverId>
        </configuration>
      </plugin>
    </plugins>

Please add your prefer profile name in the fabric8.profile, and the matching server ID in the setting.xml in fabric8.serverId.

    <properties>
        <fabric8.profile>blogDemo</fabric8.profile>
        <fabric8.serverId>fabric8.projectA.repo</fabric8.serverId>
    </properties>


To make sure our application is bundle ready, include the following plugin to generate the MANIFEST-FILE of the bundle. (I added this because some of the archetype does not have this, you will have to add manually.)

Don't forget to replace your preferred bundle name in the Bundle-SymbolicName tag, and the java source package in Private-Package tag.

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.7</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>YourBundleName</Bundle-SymbolicName>
            <Private-Package>YourJavaSourcePackage</Private-Package>
            <Import-Package></Import-Package>
          </instructions>
        </configuration>

      </plugin>

The one I didn't mention is the Repository URL, basically there are several repo you can point to.Normally I would set it in the setting.xml, but you can also put it in the pom.xml. I have included 3 in the example below. But feel free to change it.

So, here is an example pom.xml for you to reference.



  4.0.0

  org.blogdemo
  tipdemo
  bundle
  1.0.0-SNAPSHOT

  Christina's Blog Demo
  http://wei-meilin.blogspot.com/2014/06/red-hat-fusea-mq-tips-maven-pomxml-for.html

  
    UTF-8
    UTF-8
    6.1.0.redhat-379
    blogDemo
    fabric8.demo.repo
  

  
    
      release.fusesource.org
      FuseSource Release Repository
      http://repo.fusesource.com/nexus/content/repositories/releases
      
        false
      
      
        true
      
    
    
     ea.fusesource.org
     FuseSource Community Early Access Release Repository
     http://repo.fusesource.com/nexus/content/groups/ea
     
      false
     
     
      true
     
        
    
      snapshot.fusesource.org
      FuseSource Snapshot Repository
      http://repo.fusesource.com/nexus/content/repositories/snapshots
      
        true
      
      
        false
      
    
  

  
    
      release.fusesource.org
      FuseSource Release Repository
      http://repo.fusesource.com/nexus/content/repositories/releases
      
        false
      
      
        true
      
    
    
     ea.fusesource.org
     FuseSource Community Early Access Release Repository
     http://repo.fusesource.com/nexus/content/groups/ea
     
      false
     
     
      true
     
          
    
      snapshot.fusesource.org
      FuseSource Snapshot Repository
      http://repo.fusesource.com/nexus/content/repositories/snapshots
      
        true
      
      
        false
      
    
  
  
        
            
                org.jboss.fuse.bom
                jboss-fuse-parent
                ${jboss.fuse.bom.version}
                pom
                import
            
        
     
  
    
      org.apache.camel
      camel-core
    
    
      org.apache.camel
      camel-spring
    

    
    
      org.slf4j
      slf4j-api
    
    
      org.slf4j
      slf4j-log4j12
    
    
      log4j
      log4j
    

    
    
      org.apache.camel
      camel-test-spring
      test
    
  

  
    install

    
      
        org.apache.maven.plugins
        maven-compiler-plugin
        2.5.1
        
          1.6
          1.6
        
      
      
        org.apache.maven.plugins
        maven-resources-plugin
        2.6
        
          UTF-8
        
      

      
      
        org.apache.camel
        camel-maven-plugin
        2.12.0.redhat-610379
      

      
      
        org.apache.felix
        maven-bundle-plugin
        2.3.7
        true
        
          
            tipdemo
            org.blogdemo.tipdemo.*
            
          
        
      
      
      
      
     io.fabric8
     fabric8-maven-plugin
     
     
       ${fabric8.profile}
       ${fabric8. serverId}
     
   
    
  




Now, that's see how it works. (to see how to create a project with this demo, please see this post)
First make sure you have started your Red Hat JBoss Fuse. Go to http://IP:8181/ and logon, check your profiles under WIKI,


In a command mode console, go to your project directory(where the pom.xml is),
that's compile and install it by running,

mvn install




And that's start deploying it by running

mvn fabric8:deploy -Dfabric8.version=1.0




in the screen you will see a BUILD SUCCESS, go back to the console, you will find the profile we've just created!


create a container and add the profiles we needed to run,



in the runtime/container screen, you will see the profile has successfully installed on the container.


And you can always change the content and deploy a different version.


Depends on the version of profile you assign to, the container will correctly pick up the correct version of your project and run!

A. Modify project content


B.Run Maven plugin

mvn install

mvn fabric8:deploy -Dfabric8.version=2.0

C. Create container and add version 2.0


D. See result log in the "anothercontainer" console.




Comments

Luigi Celano said…
Hi there,
if I wanted to deploy on a different server than localhost using an IP address, what configuration parameters would I need to change?
Christina Lin said…
All you have to do is add jolokiaUrl in your fabric8-maven-plugin settings. For example:

<plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId>
<version>1.0.0.redhat-412</version> <configuration> <jolokiaUrl>http://172.20.10.3:8181/jolokia</jolokiaUrl>
</configuration>
</plugin>
Luigi Celano said…
Thanks for that! What I am trying to do now is to Continuously deploy the profile into the container I created. Now I understand that after executing fabric8:deploy you have to manually associate the profile to the container. Do you have any suggestions on how to automatically deploy and associate the profile to the container through Maven script for example?

Cheers
L

Popular posts from this blog

JBoss EAP 6 - 效能調校 (一) DataSource 的 Connection Pool

效能沒有什麼Best Practice, 反正能調整的就那些。 通常,一個程式的效能大概有70-80% 都跟程式怎麼寫的其實比較有關係。

最近我最疼愛的小貓Puji 因為膀胱結石開刀的時候過世了,心情很差請原諒我的口氣沒有很好,也沒有心情寫部落格。

Puji R.I.P.

=======================正文=======================

這個題目很多人叫我寫,可是這題目好大,這分明就是整死我咩~
所以我會分幾段慢慢寫。

JBoss 的 SubsystemDatasource WebWeb Service EJB Hibernate JMSJCAJVM 調校OS (作業系統)

先來看一下 DataSource Subsystem, DataSource 的部分主要是針對Connection Pool 做調校。

通常,程式都會需要跟資料庫界接,電腦在本機,尤其是在記憶體的運算很快,但是一旦要外部的資源連接,就是會非常的耗資源。所以現在的應用程式伺服器都會有個Pool 放一些先連接好的 資料庫connection,當程式有需要的時候就可以馬上提供,而不用花那些多餘的資源去連接資料庫。

這就是為什麼要針對Connection Pool 去做調校。

以下會討論到的參數,都是跟效能比較有關係,Datasource 還有很多參數,像是檢核connection 是否正確的,我都不會提到。如果你追求的是非常快速的效能,那我建議你一個檢核都不要加。當然,這樣就會為伺服器上面執行的程式帶來風險。這就是你要在效能與正確,安全性上面的取捨了。 (套句我朋友說的話,不可能又要馬兒好,又要馬兒不吃草的..)

最重要的調校參數就是 Connection 的 Pool 數量。(也就是那個Pool 裡面要放幾條的connection.) 這個參數是每一個應用程式都不一樣的。

min-pool-size 

Connection Pool 最少會存留的connection 數量

max-pool-size 

Connection Pool 最多可以開啓的 connection 數量

prefill

事先將connection pool 裡面建立好min-pool-size 的connection.

我的建議是觀察一下平常程式要用到的量設定為 min-pool-size 。
加上…

Red Hat Fuse - Announcing Fuse 7 Tech preview 3 release.

Red Hat Fuse 7.0 technical preview three is out today! On the pathway to become one of the best cloud-native integration platform, Fuse gives developer freedom to choose how they want to develop the integration solution, where they want to deploy it and capabilities to address new integration personas that do not have development experience.
By supporting the three major runtime, developer is free to work on the runtime of their choice.By supporting standalone and cloud deployment, it simplifies the complexity to distinguish between these environments, allowing application to deploy freely among the environment of your choice. All levels of developers are welcome, you can either dive deep into creating customize complex integration logic, or using the new low code platform to quickly build a simple integration. In this Tech Preview release you get it all.
Fuse StandaloneSpring-boot for microserviceKaraf 4 for OSGi loverJBoss EAP for JavaEE developersFuse on OpenShiftPlugins for easy co…

The rise of Agile Integration, Integration is not DEAD nor LAME!

I wanted to blog about this for a very long time, but because of work and being too lazy to turn on my laptop on the weekends, now I finally have a couple of hours to sit down and start blogging.

"Integration is DEAD."
"No, no, let's talk about microservice!!"
"What is that again? Integration, you mean SOA? It's lame... ".

These makes the majority of the percentage when I talk about Integration. In fact, if you happen to be in any the software conference, you see the rooms full when it's about "container" and "microservice." I understand the nature of a developer, always seeking for the latest and greatest technology out there. BUT!! In my opinion, I don't think Integration is going AWAY if you containerize your application. Neither does it will DISAPPEAR in a microservice architecture. In fact, Integration just gets more complicated and tricky when you try to break an application into smaller pieces and have them runni…