Chapter 9. To Publish a Fuse Project to JBoss Fuse

This tutorial walks you through the process of publishing an Apache Camel project to Red Hat JBoss Fuse. It assumes that you have an instance of Red Hat JBoss Fuse installed on the same machine on which you are running the Red Hat JBoss Fuse Tooling.

Goals

In this tutorial you will:

  • Define a Red Hat JBoss Fuse server
  • Configure the publishing options
  • Start up the Red Hat JBoss Fuse server and publish the CBRroute project
  • Connect to the Red Hat JBoss Fuse server
  • Verify whether the CBRroute project’s bundle was successfully built and published
  • Uninstall the CBRroute project

Prerequisites

To complete this tutorial you will need:

Defining a Red Hat JBoss Fuse Server

To define a server:

  1. Open Fuse Integration perspective.
  2. Click the Servers tab in the lower, right panel to open the Servers view.
  3. Click the link No servers are available. Click this link to create a new server…​ to open the Define a New Server page.

    Note

    To define a new server when one is already defined, right-click inside the Servers view to open the context menu, and then select menu:New[ > > Server > ].

  4. Expand the JBoss Fuse node to expose the available server options:

    tutDefineNewServer
  5. Click JBoss Fuse 6.3 Server.
  6. Accept the defaults for Server’s host name (localhost) and Server name (JBoss Fuse 6.3 Runtime Server), and then click Next to open the JBoss Fuse Runtime page:

    tutFuseRuntimeDef1
    Note

    If you do not have JBoss Fuse 6.3 already installed, you can download it now using the Download and install runtime…​ link.

    Note

    If you have already defined a JBoss Fuse 6.3 server, the tooling skips this page, and instead displays the configuration details page shown in [configDetails].

  7. Accept the default for Name (JBoss Fuse 6.3 Runtime).
  8. Click Browse next to the Home Directory field, to navigate to the JBoss Fuse 6.3 installation and select it.
  9. Select the runtime JRE from the drop-down menu next to Execution Environment.

    Select either JavaSE-1.8 (recommended) or JavaSE-1.7. If neither appears as an option, click the Environments…​ button and select either version from the list.

    Note

    The JBoss Fuse 6.3 server requires Java 8 (recommended) or Java 7. To select either version for the Execution Environment, you must have previously installed it.

  10. Leave the Alternate JRE option as is.

    tutFuseRuntimeDef2
  11. Click Next to save the runtime definition for JBoss Fuse 6.3 Server and open the JBoss Fuse server configuration details page:

    NewServerDetailsTut
  12. Accept the default for SSH Port (8101).

    The runtime uses the SSH port to connect to the server’s Karaf shell. If this default is incorrect, you can discover the correct port number by looking in the Red Hat JBoss Fuse installDir/etc/org.apache.karaf.shell.cfg file.

  13. In User Name, enter the name used to log into the server.

    This is a user name stored in the Red Hat JBoss Fuse installDir/etc/users.properties file.

    Note

    If the default user has been activated (uncommented) in the /etc/users.properties file, the tooling autofills User Name and Password with the default user’s name and password, as shown in [configDetails].

    If one has not been set, you can either add one to that file using the format user=password,role (for example, joe=secret,Administrator), or you can set one using the karaf jaas command set:

    • jaas:realms — to list the realms
    • jaas:manage --index 1 — to edit the first (server) realm
    • jaas:useradd <username> <password> — to add a user and associated password
    • jaas:roleadd <username> Administrator — to specify the new user’s role
    • jaas:update — to update the realm with the new user information

      If a jaas realm has already been selected for the server, you can discover the user name by issuing the command JBossFuse:karaf@root>jaas:users.

  14. In Password:, enter the password required for User name to log into the server.

    This is the password set either in Red Hat JBoss Fuse’s installDir/etc/users.properties file or by the karaf jaas commands.

  15. Click Finish.

    JBoss Fuse 6.3 Runtime Server [stopped, Synchronized] appears in the Servers view.

  16. In the Servers view, expand JBoss Fuse 6.3 Runtime Server [stopped, Synchronized]:

    JBFuseServersView

    JMX[Disconnected] appears as a node under JBoss Fuse 6.3 Runtime Server [stopped, Synchronized] entry.

Configuring the publishing options

Using publishing options, you can configure how and when your CBRroute project is published to a running server:

  • Automatically, immediately upon saving changes made to the project
  • Automatically, at configured intervals after you have changed and saved the project
  • Manually, when you select a publish operation

In this tutorial, you are going to configure immediate publishing upon saving changes to the CBRroute project. To do so:

  1. In the Servers view, double-click the JBoss Fuse 6.3 Runtime Server [stopped, Synchronized] entry to display its overview:

    srvEditorPubOpts
  2. On the server’s Overview page, expand the Publishing section to expose the options.

    Make sure the option Automatically publish when resources change is enabled.

    Change the value of Publishing interval to speed up or delay publishing the project when changes have been made.

Note

To configure manual publishing:

  • Enable the Never publish automatically option on the server’s Overview page.
  • Disable the If server started, publish changes immediately option on the server’s Add and Remove page.

Then to manually publish changes made to selective resources configured on the running server, use the Full Publish option on the resource’s context menu in the Servers view. The Incremental Publish option is not supported and clicking it results in a full publish.

Starting the Red Hat JBoss Fuse server

This section provides instructions for starting the Fuse server and then assigning the CBRroute module to it for immediate publishing.

  1. In the Servers view, select JBoss Fuse 6.3 Runtime Server and click start server icon to start it.

    Important

    A warning that the host identification has changed may appear. Click yes to replace the key only if the JBoss Fuse 6.3 server runtime is installed on the same machine where Red Hat JBoss Fuse Tooling is running! Otherwise click no and contact your system administrator.

  2. Wait a few seconds for JBoss Fuse 6.3 Server to start up. When it does:

    • The Terminal view displays the JBoss Fuse splash screen:

      tutServerStartShellV
    • Servers view displays:

      tutServerStartServerV
    • JMX Navigator displays JBoss Fuse 6.3 Runtime Server[Disconnected]:

      tutServerStartJMXNav
  3. In the Servers view, right-click JBoss Fuse 6.3 Runtime Server [Started] to open the context menu.
  4. Select Add and Remove to open the Add and Remove page:

    tutAddRemove1

    Make sure the option If server is started, publish changes immediately is checked.

  5. Select CBRroute and click Add to assign it to the JBoss Fuse server;

    tutAddRemove2
  6. Click Finish.

    tutCBRrtePublishedSrvV
    • JBoss Fuse 6.3 Runtime Server [Started, Synchronized]

      Note

      For a server, synchronized means that all modules published on the server are identical to their local counterparts.

    • CBRroute [Started, Synchronized]

      Note

      For a module, synchronized means that the published module is identical to its local counterpart. Because automatic publishing is enabled, changes made to the CBRroute project are published in seconds (according to the value of the Publishing interval).

    • JMX[Disconnected]

Connecting to the JBoss Fuse 6.3 runtime server

When you connect to the JBoss Fuse 6.3 Runtime Server, you can see the published elements of your CBRroute project and interact with them. The instructions in this section will show a display such as the following:

tutSrvJMXConnected
  1. In the Servers view, double-click JMX[Disconnected] to connect to the runtime server.
  2. Expand the Camel folder in the Servers view or JMX Navigator to expose the elements of the CBRroute.

    You can interact with the CBRroute routing context using either the Servers view or JMX Navigator, but JMX Navigator provides more room to expand the routing context’s nodes, making it easier for you to access them.

    Note

    Once the _context1 node appears in JMX Navigator under Server Connections (or in the Servers view under JMX[Connected]), you can start tracing on it, as described in Chapter 7, To Trace a Message Through a Route.

  3. Click the Bundles node to populate the Properties view with the list of bundles installed on the JBoss Fuse 6.3 Runtime Server:

    tutCBRrouteBundleInstall

    Start typing CBRroute in the Properties view’s Search field to quickly determine whether your project’s CBRroute bundle is included in the list. Note that it is the last bundle in the list, identified by its Symbolic Name, CBRroute, which is the name you gave your project when you created it.

    Note

    Alternatively, you can issue the osgi:list command in the Terminal view to see a generated list of bundles installed on the JBoss Fuse server runtime. The tooling uses a different naming scheme for OSGi bundles displayed by the osgi:list command. In this case, the command returns Empty Camel Blueprint Project [CBRroute], which appears at the end of the list of installed bundles.

    In the <build> section of project’s pom.xml file, you can find the bundle’s symbolic name and its bundle name (OSGi) listed in the maven-bundle-plugin entry:

    tutBundleNamesPom

Uninstalling the CBRroute project

Note

You do not need to disconnect the JMX connection or stop the server to uninstall a published resource.

To remove the CBRroute resource from the JBoss Fuse runtime server:

  1. In the Servers view, right-click JBoss Fuse 6.3 Runtime Server to open the context menu.
  2. Select Add and Remove:

    tutUnpubCBRroute
  3. In the Configured column, select CBRroute, and then click Remove to move the CBRroute resource to the Available column.
  4. Click Finish.
  5. In the Servers view, right-click JMX[Connected] to open the context menu, and then click Refresh.

    The Camel tree under JMX[Connected] disappears.

    Note

    In JMX Navigator, the Camel tree under Server Connections > JBoss Fuse 6.3 Runtime Server[Connected] also disappears.

  6. With the Bundles page displayed, start typing CBRroute` in the Properties view’s Search field to verify that the bundle has been removed.