Este contenido no está disponible en el idioma seleccionado.

Chapter 10. Integrating a Camel application with the A-MQ broker


This tutorial shows how to deploy a quickstart using the A-MQ image.

10.1. Building and deploying a Spring Boot Camel A-MQ quickstart

This quickstart demonstrates how to connect a Spring Boot application to AMQ Broker and use JMS messaging between two Camel routes using Fuse on OpenShift.

Prerequisites

Procedure

  1. Log in to the OpenShift server as a developer.

    oc login -u developer -p developer
  2. Create a new project for quickstart, for example:.

    oc new-project quickstart
  3. Retrieve the quickstart project by using the Maven archetype:

    mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeCatalog=https://maven.repository.redhat.com/ga/io/fabric8/archetypes/archetypes-catalog/2.2.0.fuse-sb2-790047-redhat-00004/archetypes-catalog-2.2.0.fuse-sb2-790047-redhat-00004-archetype-catalog.xml -DarchetypeGroupId=org.jboss.fuse.fis.archetypes -DarchetypeArtifactId=spring-boot-camel-amq-archetype -DarchetypeVersion=2.2.0.fuse-sb2-790047-redhat-00004
  4. Navigate to the quickstart directory fuse713-spring-boot-camel-amq.

    cd fuse713-spring-boot-camel-amq
  5. Run the following commands to apply configuration files to AMQ Broker. These configuration files create the AMQ Broker user and the queue, both with the admin privileges.

    oc login -u admin -p admin
    
    oc apply -f src/main/resources/k8s
  6. Create the ConfigMap for the application, for example:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: spring-boot-camel-amq-config
      namespace: quickstarts
    data:
      service.host: 'fuse-broker-amqps-0-svc'
      service.port.amqp: '5672'
      service.port.amqps: '5671'
  7. Run the mvn command to deploy the quickstart to the OpenShift server, by using the ImageStream from Step 3:

    mvn oc:deploy -Popenshift -Djkube.generator.fromMode=istag -Djkube.generator.from=openshift/fuse-java-openshift:1.13
  8. To verify that the quickstart is running successfully:

    1. 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).
    2. In the left hand side panel, expand Home and then click Status to view the Project Status page for openshift project.
    3. Click fuse713-spring-boot-camel-amq to view the Overview information page for the quickstart.
    4. In the left hand side panel, expand Workloads.
    5. Click Pods and then click fuse713-spring-boot-camel-amq-xxxxx. The pod details for the quickstart are displayed.
    6. Click Logs to view the logs for the application.

      The output shows the messages are sent successfully.

      10:17:59.825 [Camel (camel) thread #10 - timer://order] INFO  generate-order-route - Generating order order1379.xml
      10:17:59.829 [Camel (camel) thread #8 - JmsConsumer[incomingOrders]] INFO  jms-cbr-route - Sending order order1379.xml to the UK
      10:17:59.829 [Camel (camel) thread #8 - JmsConsumer[incomingOrders]] INFO  jms-cbr-route - Done processing order1379.xml
      10:18:02.825 [Camel (camel) thread #10 - timer://order] INFO  generate-order-route - Generating order order1380.xml
      10:18:02.829 [Camel (camel) thread #7 - JmsConsumer[incomingOrders]] INFO  jms-cbr-route - Sending order order1380.xml to another country
      10:18:02.829 [Camel (camel) thread #7 - JmsConsumer[incomingOrders]] INFO jms-cbr-route - Done processing order1380.xml
  9. To view the routes on the web interface, click Open Java Console and check the messages in the AMQ queue.
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.