Ok

En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies. Ces derniers assurent le bon fonctionnement de nos services. En savoir plus.

Using JBoss Fuse Integration on JBoss EAP

JBoss Fuse Integration is the legitimate heir of Apache ServiceMix and Progress Software Fuse. It has been acquired by RedHat in 2012 and, in the beginning, it was available in two architectures: JBoss Fuse, which ran on OSGi platforms, and JBoss Fuse Service Works (FSW), running on Java EE platforms. Currently the two releases, dedicated to these two architectures, were unified in a unique one: JBoss Fuse Integration. It can be run on OSGi platforms, like Apache Karaf, or on Java EE platforms, like JBoss EAP. This article a show how easy is to develop and deploy Apache Camel routes based services using JBoss Fuse Integartion on JBoss EAP. You may find here the project which illustrates the article.

The first step to perform, after having downloaded and installed JBoss EAP 6.4, is to add to the existent installation JBoss Fuse Integration 6.3, as described here. This process goes through downloading JBoss Fuse Integration 6.3 from the RedHat Customer Portal, unzip it into the existent JBoss EAP home directory and executing the install script. This process should terminate successfully and you’ll find yourself with a Java EE 6 full compliant platform which natively includes Apache Camel, Switchyard, Riftsaw and other Fuse tools.

The money-transfer project, which illustrates this blog ticket, is a Camel route performing quite complex integration and transformation process. Thanks to Fuse Integration and JBDS (JBoss Developer Studio) this complex service can be developed and tested in minutes. Here is what it does:

  1. XML files containing money transfer orders are landing in a dedicated file-system directory. Their arrival in this landing directory triggers the route execution.
  2. Once a file is received, its XML content is unmarshalled, by JAXB, into Java objects.
  3. The result is a list containing a certain number of money transfer orders. This list is splitted out such that to separate each money transfer order of the list.
  4. Each money transfer order will be converted in JSON.
  5. The result of this conversion will be stored in a JMS destination on the EAP platform.
  6. A 2nd route listens on the given JMS destination and, as soon as a message is received, it will be processed. In our case, for simplicity sake, this processing simply consists in displaying the message into the EAP log file.
  7. Different messages are logged into the EAP log file at different stages of the process, such that to trace the route execution and to facilitate debugging.

The steps above imply the use of Enterprise Integration Patterns (EIP) like transformers, splitters, wire-taps, etc. Their implementation would take several days, perhaps one week, to an experienced Java developer. But using Apache Camel on EAP provided by Fuse Integration, such an implementation is done in minutes. The first thing to notice is that JBDS 11.1.0.GA provides a Fuse Integration project wizard. Just click File->New->Fuse Integration Project and let yourself guided by the wizard. It will generate a maven project with all the required dependencies and plugins. During the generation process, you may choose either to generate an empty project, or a skeleton. In this last case, you may choose between Java DSL, Blueprint DSL or Spring DSL.

For those who, like me, prefer to manually craft their stuff, you may of course create a normal maven project and add to it the dependencies and plugins you need. This is the way that the money-transfer project has been done. If you choose to use Spring or Blueprint DSL, JBDS offers you a Fuse Route Editor which greatly facilitates the routes implementation. Both Spring DSL and Blueprint DSL are complex formal notations with an XML syntax, consisting in long lines of dozens of characters and using the Fuse Route Editor in order to edit them dramatically can increase your productivity. A Palette located on the right side of the Fuse Integration perspective in Eclipse presents to the developer the full set of available tools: Components, Routing, Control Flow, Transformation, Miscellaneous. The developer simply selects the desired tool in the Palette and drops it on the canvas. Then the Property dialog opens and allows him to configure and customize the chosen tool, without even having to know the Camel syntax. The image below shows the Camel diagram of the money-transfer project, exported from the workspace to a JPG file.

CamelContext.jpg

 

 

 

 

 

To run the application, perform the following steps:

  1. Start the JBoss EAP server with the full profile, as follows:

    $JBOSS_HOME/bin/standalone.sh –c standalone-full.xml

  2. Create a JMS destination, as follows:

    $JBOSS_HOME/bin/jboss-cli.sh –c
    [standalone@localhost:9999 /]
    jms-queue add --queue-address=bankQ --entries=queue/bankQ

  3. Check whether the JMS queue has been created successfully, as follows:

    [standalone@localhost:9999 /] /subsystem=messaging/hornetq-server=default/jms-queue=bankQ:read-resource
    {
    "outcome" => "success",
        "result" => {
            "durable" => false,
            "entries" => ["java:/jms/queue/bankQ"],
            "selector" => undefined
        }
    }
    [standalone@localhost:9999 /]

  4. Clone the git project from the GitHub, as follows:

    git clone https://github.com/nicolasduminil/money-transfer.git

  5. Build and deploy the project, as follows:

    mvn clean install
    mvn –pl money-transfer-war jboss-as:deploy

  6. Now that the project is built and deployed, you can test it by copying the file src/main/resources/money-transfer.xml from the money-transfer-war project into the $JBOSS_HOME/data/temp/inbox directory. This will automatically trigger your Camel route and you can admire the results in the EAP log file.

Congratulations, you just have successfully developed and deployed your first integration complex project on JBoss EAP. Those of you who already have deployed Camel routes in more classical environments, Java SE, will certainly appreciate the facility.

Les commentaires sont fermés.