Chapter 11. 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

11.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

  1. Add the view role to the default service account to enable clustering. This grants the user the view access to the default service account. Service accounts are required in each project to run builds, deployments, and other pods. Enter the following oc client commands in a shell prompt:

    oc login -u developer -p developer
    oc policy add-role-to-user view -z default
  2. View the installed Fuse on OpenShift templates.

    oc get template -n openshift
  3. Enter the following command to create the resources required for running the Red Hat Fuse 7.5 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-fuse75-eap-camel-cdi
    
    --> Creating resources ...
        service "s2i-fuse75-eap-camel-cdi" created
        service "s2i-fuse75-eap-camel-cdi-ping" created
        route.route.openshift.io "s2i-fuse75-eap-camel-cdi" created
        imagestream.image.openshift.io "s2i-fuse75-eap-camel-cdi" created
        buildconfig.build.openshift.io "s2i-fuse75-eap-camel-cdi" created
        deploymentconfig.apps.openshift.io "s2i-fuse75-eap-camel-cdi" created
    --> Success
        Access your application via route 's2i-fuse75-eap-camel-cdi-OPENSHIFT_IP_ADDR'
        Build scheduled, use 'oc logs -f bc/s2i-fuse75-eap-camel-cdi' to track its progress.
        Run 'oc status' to view your app.
  4. 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 username developer and password, developer).
  5. In the left hand side panel, expand Home. Click Status to view the Project Status page. All the existing applications in the selected namespace (for example, openshift) are displayed.
  6. Click s2i-fuse75-eap-camel-cdi to view the Overview information page for the quickstart.

    eap image s2i source 08

  7. Click the Resources tab and then click the link displayed in the Routes section to access the application.

    eap image s2i source 07

    The link has the form http://s2i-fuse75-eap-camel-cdi-OPENSHIFT_IP_ADDR. This shows a message like the following in your browser:

    Hello world from 172.17.0.3
  8. You can also specify a name using the name parameter in the URL. For example, if you enter the URL, http://s2i-fuse75-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
  9. Click View Logs to view the logs for the application.
  10. To shut down the running pod,

    1. Click the Overview tab to return to the overview information page of the application.
    2. Click the eap image s2i source 06 icon next to Desired Count. The Edit Count window is displayed.
    3. Use the down arrow to scale down to zero to stop the pod.

11.2. Structure of the JBoss EAP application

You can find the source code for the Red Hat Fuse 7.5 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.

11.3. JBoss EAP quickstart templates

The following S2I templates are provided for Fuse on JBoss EAP:

Table 11.1. JBoss EAP S2I templates
NameDescription

JBoss Fuse 7.5 Camel A-MQ with EAP (eap-camel-amq-template)

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.5 Camel CDI with EAP (eap-camel-cdi-template)

Demonstrates using the camel-cdi component to integrate CDI beans with Camel routes.

Red Hat Fuse 7.5 CXF JAX-RS with EAP (eap-camel-cxf-jaxrs-template)

Demonstrates using the camel-cxf component to produce and consume JAX-RS REST services.

Red Hat Fuse 7.5 CXF JAX-WS with EAP (eap-camel-cxf-jaxws-template)

Demonstrates using the camel-cxf component to produce and consume JAX-WS web services.

Red Hat Fuse 7.5 Camel JPA + MySQL (Ephemeral) with EAP eap-camel-jpa-template

Demonstrates how to connect a Camel application with Red Hat Fuse on EAP to a MySQL database and expose a REST API. This example creates two containers, one container to run as a MySQL server, and another running the Camel application which acts as as a client to the database.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.