Chapter 9. To Publish a Fuse Project to Red Hat JBoss Fuse
Abstract
This tutorial walks you through the process of deploying an Apache Camel project into 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
- access to a Red Hat JBoss Fuse 6.2 instance
- the CBRroute project you updated in Chapter 8, To Test a Route with JUnit
Defining a Red Hat JBoss Fuse Server
To define a server:
- Open Fuse Integration perspective.
- Click the Servers tab in the lower, right panel to open the Servers view.
- Click the link No servers are available. Click this link to create a new server... to open the Define a New Server page.NoteTo define a new server when one is already defined, right-click inside Servers view to open the context menu, and then select
. - Expand the
JBoss Fuse
node to expose the available server options: - Click
JBoss Fuse 6.2 Server
. - Accept the defaults for Server's host name (localhost) and Server name (JBoss Fuse 6.2 Runtime Server), and then click to open the JBoss Fuse Runtime page:NoteIf you do not have JBoss Fuse 6.2 already installed, you can download it now using the Download and install runtime... link.NoteIf you have already defined a JBoss Fuse 6.2 server, the tooling skips this page, and instead displays the configuration details page shown in Step 11.
- Accept the default for Name (JBoss Fuse 6.2 Runtime).
- In Home Directory, enter the path where the JBoss Fuse 6.2 installation is located, or click to find and select it.
- Select the runtime JRE from the drop-down menu next to Execution Environment.Select either JavaSE-1.7 or JavaSE-1.8. If neither appears as an option, click the Environments... button and select either version from the list.NoteThe JBoss Fuse 6.2 server requires Java 7 or Java 8. To select either version for the Execution Environment, you must have previously installed it.
- Leave the Alternate JRE option as is.
- Click JBoss Fuse server configuration details page:to save the runtime definition for JBoss Fuse 6.2 Server and open the
- 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. - 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.NoteIf 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 Step 11.If one has not been set, you can either add one to that file using the formatuser=password,role
(for example,joe=secret,Administrator
), or you can set one using the karafjaas
command set:jaas:realms
—to list the realmsjaas:manage --index 1
—to edit the first (server) realmjaas:useradd <username> <password>
—to add a user and associated passwordjaas:roleadd <username> Administrator
—to specify the new user's rolejaas: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 commandJBossFuse:karaf@root>
jaas:users
. - 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 karafjaas
commands. - Clickto open the resources page:
- Select CBRroute, and click to assign it to the JBoss Fuse server.
- Click.
JBoss Fuse 6.2 Runtime Server [stopped]
appears in Servers view. - Inview, expand
JBoss Fuse 6.2 Runtime Server [stopped]
:Themodule and appear as nodes underJBoss Fuse 6.2 Runtime Server [stopped]
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:
- Inview, double-click the
JBoss Fuse 6.2 Runtime Server [stopped]
entry to open the server's editor: - On the server editor's Overview page, expand the Publishing section to expose the options.Make sure the optionis enabled.Change the value ofto speed up or delay publishing the project when changes have been made.
Note
To configure manual publishing:
- disable the Add and Remove pageoption on the server's
- enable the Overview pageoption on the server editor's
Then to manually publish changes made to selective resources configured on the running server, use the Servers view. The option is not supported and clicking it results in a full publish.
option on the resource's context menu in Starting up Red Hat JBoss Fuse server
Because you enabled the automatic publishing option, when you start up the
JBoss Fuse 6.2 Runtime Server
, the publish mechanism automatically publishes the CBRroute to the server.
- In Servers view, select
JBoss Fuse 6.2 Runtime Server
and click to start it.ImportantA warning that the host identification has changed may appear. Clickto replace the key ONLY if the JBoss Fuse 6.2 server runtime is installed on the same machine where Red Hat JBoss Fuse Tooling is running! Otherwise click and contact your system administrator. - Wait a few seconds for JBoss Fuse 6.2 Server to start up. When it does:
- Shell view displays the JBoss Fuse splash screen:
- Servers view displays:
JBoss Fuse 6.2 Runtime Server [Started, Synchronized]
NoteFor a server, synchronized means that all modules published on the server are identical to their local counterparts.CBRroute [Started, Synchronized]
NoteFor 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 ).JMX[Disconnected]
- JMX Navigator displays
JBoss Fuse 6.2 Runtime Server[Disconnected]
:
Connecting to the JBoss Fuse 6.2 runtime server
When you connect to the
JBoss Fuse 6.2 Runtime Server
, you can see the published elements of your CBRroute project and interact with them.
- In Servers view, double-click JMX[Disconnected] to connect to the runtime server.ImportantIf the CBRroute project contains a failed JUnit test, the published module will not be started nor its bundle installed. The published module will appear in Servers view under
JBoss Fuse 6.2 Runtime Server[Started, Synchronized]
asCBRroute[Synchronized]
.You need to correct the JUnit test case (see the section called “Modifying the CamelContextXmlTest file ” for details) so that it runs on the CBRroute without errors, and save the updated test file. Saving the test file will trigger immediate publishing when that option is enabled. The module should then be started and its bundle installed. - Expand the Camel node in JMX Navigator to expose the elements of the CBRroute.You can interact with the CBRroute routing context using either 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.NoteOnce the
blueprintCamel
node appears in JMX Navigator under Server Connections (or in Servers view under JMX[Connected]), you can start tracing on it, as described in Chapter 7, To Trace a Message Through a Route. - Click thenode to populate view with the list of bundles installed on the
JBoss Fuse 6.2 Runtime Server
.Start typing cbr-route in view's Search tool to quickly determine whether your project'scbr-route
bundle is included in the list. Note that it is the last bundle in the list, identified by its ,cbr-route
, which is the Artifact Id you gave it in Step 6 when you created the CBRroute project.NoteAlternatively, you can issue the list command in view to see a generated list of installed bundles.
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 JBoss Fuse 6.2 Runtime Server:
- In Servers view, right-click
JBoss Fuse 6.2 Runtime Server
to open the context menu. - Select:
- In the Configured column, select CBRroute, and then click to move the CBRroute resource to the Available column.
- Click.
- In Servers view, right-click JMX[Connected] to open the context menu, and then click .The Camel tree under JMX[Connected] disappears.NoteIn JMX Navigator, the Camel tree under Server Connections > JBoss Fuse 6.2 Runtime Server[Connected] also disappears.
- With the Bundles page displayed, start typing cbr-route in view's Search tool to verify that the bundle has been removed.