검색

이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 8. Integrating a Camel Application with the A-MQ Broker

download PDF

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

8.1. Building and Deploying a Spring Boot Camel A-MQ Quickstart

This example requires a JBoss A-MQ 6 image and deployment template. If you are using CDK 3.1.1+, JBoss A-MQ 6 images and templates should be already installed in the openshift namespace by default.

Prerequisites

Procedure

  1. Get ready to build and deploy the quickstart:

    1. Log in to OpenShift as a developer.

      oc login -u developer -p developer
    2. Create a new project amq-quickstart.

      oc new-project amq-quickstart
    3. Determine the version of the A-MQ 6 images and templates installed.

      $ oc get template -n openshift

      You should be able to find a template named amqXX-basic, where XX is the version of A-MQ installed in Openshift.

  2. Deploy the A-MQ 6 image in the amq-quickstart namespace (replace XX with the actual version of A-MQ found in previous step).

    $ oc process openshift//amqXX-basic -p APPLICATION_NAME=broker -p MQ_USERNAME=admin -p MQ_PASSWORD=admin -p MQ_QUEUES=test -p MQ_PROTOCOL=amqp -n amq-quickstart | oc create -f -
    Note

    This oc command could fail, if you use an older version of oc. This syntax works with oc versions 3.5.x (based on Kubernetes 1.5.x).

  3. Add a user role that is needed for discovery of mesh endpoints (through Kubernetes REST API agent).

    $ oc policy add-role-to-user view system:serviceaccount:amq-quickstart:default
  4. Create the quickstart project using the Maven workflow.

    $ 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-740017-redhat-00003/archetypes-catalog-2.2.0.fuse-740017-redhat-00003-archetype-catalog.xml \
    -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \
    -DarchetypeArtifactId=spring-boot-camel-amq-archetype \
    -DarchetypeVersion=2.2.0.fuse-740017-redhat-00003
  5. The archetype plug-in switches to interactive mode to prompt you for the remaining fields.

    Define value for property 'groupId': : org.example.fis
    Define value for property 'artifactId': : fuse74-spring-boot-camel-amq
    Define value for property 'version':  1.0-SNAPSHOT: :
    Define value for property 'package':  org.example.fis: :
    [INFO] Using property: spring-boot-version = 1.5.17.RELEASE
    Confirm properties configuration:
    groupId: org.example.fis
    artifactId: fuse74-spring-boot-camel-amq
    version: 1.0-SNAPSHOT
    package: org.example.fis
    spring-boot-version: 1.5.17.RELEASE
     Y: :

    When prompted, enter org.example.fis for the groupId value and fuse74-spring-boot-camel-amq for the artifactId value. Accept the defaults for the remaining fields.

  6. Navigate to the quickstart directory fuse74-spring-boot-camel-amq.

    $ cd fuse74-spring-boot-camel-amq
  7. Customize the client credentials for logging on to the broker, by setting the ACTIVEMQ_BROKER_USERNAME and ACTIVEMQ_BROKER_PASSWORD environment variables. In the fuse74-spring-boot-camel-amq project, edit the src/main/fabric8/deployment.yml file, as follows:

    spec:
      template:
        spec:
          containers:
            -
              resources:
                requests:
                  cpu: "0.2"
    #              memory: 256Mi
                limits:
                  cpu: "1.0"
    #              memory: 256Mi
              env:
              - name: AMQP_HOST
                value: broker-amq-amqp
              - name: SPRING_APPLICATION_JSON
                value: '{"server":{"undertow":{"io-threads":1, "worker-threads":2 }}}'
              - name: AMQP_USERNAME
                value: admin
              - name: AMQP_PASSWORD
                value: admin
  8. Run the mvn command to deploy the quickstart to OpenShift server.

    mvn fabric8:deploy -Popenshift
  9. To verify that the quickstart is running successfully:

    1. Navigate to the OpenShift console.
    2. Select the project amq-quickstart.
    3. Click Applications.
    4. Select Pods.
    5. Click fis-spring-boot-camel-am-1-xxxxx.
    6. Click Logs.

      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
  10. To view the routes on the web interface, click Open Java Console and check the messages in the A-MQ queue.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.