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

Red Hat JBoss Fuse - Getting Started with Fuse Integration Service 2.0 Tech preview

I just realized that I did not do a getting started for Fuse Integration Service 2.0 Tech preview before I did the pipeline demo, thanks for those of you who reminded me! :)

To get started with FIS 2.0, for people who has just getting to know the technology, here is how I interpret it. Basically, it's divide into two aspect,

1. Integration development, FIS uses Apache Camel as the core technology that creates, orchestrate, compose microservices into a super lightweight thin integration layer, and become the API provider and service orchestrator through exposing RESTful or messaging service endpoints. And you can choose to either package and run it with Spring-Boot or Karaf.


2. Application Deployment and Management, FIS takes advantages of OpenShift platform, and allows you to separately deploy the micro-integration service among distributed environment, at the same time takes care of the failover, high availability, load balancing and service lookup problem for you.


So, now we know …

Red Hat JBoss Fuse/A-MQ - Fuse and A-MQ Version 6.3 GA is released!

Fuse and A-MQ 6.3 GA has just went out. Maybe, you would think this is just only a minor version release why should I care? Hold your thoughts on that! Because they have done a lot of improvements and also added many new features into this release.

Besides various bug fixes and making sure Fuse Fabric is much more stable. There are two major change in this version update:

New Tooling in JBoss Developer Studio (JBDS) 9.1 GA. Newer Apache Camel version – Camel v2.17. I was really impressed by the work put in to make developing Camel application much simpler. First is the installation of tooling itself. Now it has a all-in-one installer so you don't need to worry about which plugins you need to check. See the videos below to see the new "Getting Started" of Fuse 6.3.



And If you notice from the above video, the presentation of camel route in JBDS has also updated. It fixed some of the miss representation of logic and making it easier to read.

Old Camel Route
New Camel Route
On …

Fuse Integration Service - Setup JBDS and create first quickstart application

Before we go and start creating our first application, I want to show you how to setup your JBoss Developer Studio, create a small application from the quickstart example and then running it on Fuse Integration Service.

I am using JBoss Developer Studio version 9, you can find it here.
After download the

jboss-devstudio-9.0.0.GA-installer-eap.jar
double-click it, and start installing with default values.

After successful installation, we will need install the plugins for Fuse, on JBoss Central view, select software update, select enable early access.


And select JBoss Fuse Development for the plugin,


Click on install, and we are all set to go!

First thing first, we want to create a Fuse project to deploy on the base of Fuse Integration Service, which is OpenShift. If you have not installed it, please go back to my previous post for instructions. So on your JBDS, right click and start creating the project. Select new, maven project, if you have installed the plugin correctly, you should …