Chapter 13. Developing an application for the JBoss EAP image
To develop Fuse applications on JBoss EAP, an alternative is to use the S2I source workflow to create an OpenShift project for Red Hat Camel CDI with EAP.
Prerequisites
- Ensure that OpenShift is running correctly and the Fuse image streams are already installed in OpenShift. See Getting Started for Administrators.
- Ensure that Maven Repositories are configured for fuse, see Configuring Maven Repositories.
13.1. Creating a JBoss EAP project using the S2I source workflow
To develop Fuse applications on JBoss EAP, an alternative is to use the S2I source workflow to create an OpenShift project for Red Hat Camel CDI with EAP.
Procedure
Add the
view
role to the default service account to enable clustering. This grants the user theview
access to thedefault
service account. Service accounts are required in each project to run builds, deployments, and other pods. Enter the followingoc
client commands in a shell prompt:oc login -u developer -p developer oc policy add-role-to-user view -z default
View the installed Fuse on OpenShift templates.
oc get template -n openshift
Enter the following command to create the resources required for running the Red Hat Fuse 7.8 Camel CDI with EAP quickstart. It creates a deployment config and build config for the quickstart. The information about the quickstart and the resources created is displayed on the terminal.
oc new-app s2i-fuse78-eap-camel-cdi --> Creating resources ... service "s2i-fuse78-eap-camel-cdi" created service "s2i-fuse78-eap-camel-cdi-ping" created route.route.openshift.io "s2i-fuse78-eap-camel-cdi" created imagestream.image.openshift.io "s2i-fuse78-eap-camel-cdi" created buildconfig.build.openshift.io "s2i-fuse78-eap-camel-cdi" created deploymentconfig.apps.openshift.io "s2i-fuse78-eap-camel-cdi" created --> Success Access your application via route 's2i-fuse78-eap-camel-cdi-OPENSHIFT_IP_ADDR' Build scheduled, use 'oc logs -f bc/s2i-fuse78-eap-camel-cdi' to track its progress. Run 'oc status' to view your app.
-
Navigate to the OpenShift web console in your browser (https://OPENSHIFT_IP_ADDR, replace
OPENSHIFT_IP_ADDR
with the IP address of the cluster) and log in to the console with your credentials (for example, with usernamedeveloper
and password,developer
). -
In the left hand side panel, expand
Home
. ClickStatus
to view theProject Status
page. All the existing applications in the selected namespace (for example, openshift) are displayed. Click
s2i-fuse78-eap-camel-cdi
to view theOverview
information page for the quickstart.Click the
Resources
tab and then click the link displayed in the Routes section to access the application.The link has the form http://s2i-fuse78-eap-camel-cdi-OPENSHIFT_IP_ADDR. This shows a message like the following in your browser:
Hello world from 172.17.0.3
You can also specify a name using the name parameter in the URL. For example, if you enter the URL, http://s2i-fuse78-eap-camel-cdi-openshift.apps.cluster-name.openshift.com/?name=jdoe, in your browser you see the response:
Hello jdoe from 172.17.0.3
-
Click
View Logs
to view the logs for the application. To shut down the running pod,
-
Click the
Overview
tab to return to the overview information page of the application. -
Click the
icon next to Desired Count. The
Edit Count
window is displayed. - Use the down arrow to scale down to zero to stop the pod.
-
Click the
13.2. Structure of the JBoss EAP application
You can find the source code for the Red Hat Fuse 7.8 Camel CDI with EAP example at the following location:
https://github.com/wildfly-extras/wildfly-camel-examples/tree/wildfly-camel-examples-5.2.0.fuse-720021/camel-cdi
The directory structure of the Camel on EAP application is as follows:
├── pom.xml ├── README.md ├── configuration │ └── settings.xml └── src └── main ├── java │ └── org │ └── wildfly │ └── camel │ └── examples │ └── cdi │ └── camel │ ├── MyRouteBuilder.java │ ├── SimpleServlet.java │ └── SomeBean.java └── webapp └── WEB-INF └── beans.xml
Where the following files are important for developing a JBoss EAP application:
- pom.xml
- Includes additional dependencies.
13.3. JBoss EAP quickstart templates
The following S2I templates are provided for Fuse on JBoss EAP:
Name | Description |
---|---|
JBoss Fuse 7.8 Camel A-MQ with EAP ( | Demonstrates using the camel-activemq component to connect to an AMQ message broker running in OpenShift. It is assumed that the broker is already deployed. |
Red Hat Fuse 7.8 Camel CDI with EAP ( | Demonstrates using the camel-cdi component to integrate CDI beans with Camel routes. |
Red Hat Fuse 7.8 CXF JAX-RS with EAP ( | Demonstrates using the camel-cxf component to produce and consume JAX-RS REST services. |
Red Hat Fuse 7.8 CXF JAX-WS with EAP ( | Demonstrates using the camel-cxf component to produce and consume JAX-WS web services. |