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

Chapter 4. Running a Route


This tutorial walks you through the process of running a route to verify that the route correctly transfers messages from the source endpoint to the sink endpoint.

Goals

In this tutorial you complete the following tasks:

  • Run a route as a local Camel context (without tests since you have not set up a test yet)
  • Send messages through the route
  • Examine the messages received by the sink endpoint to make sure that the route correctly processed the test messages

Prerequisites

To start this tutorial, you need the ZooOrderApp project resulting from:

  1. Completing the Chapter 2, Setting up your environment tutorial.
  2. One of the following:

Running the route

To run the route:

  1. Open the ZooOrderApp project.
  2. In Project Explorer, select ZooOrderApp/Camel Contexts/blueprint.xml :

    tutRunCBRrouteCamContext
  3. Right-click the blueprint.xml, and then select Run As Local Camel Context (without tests).

    Note

    If you select Local Camel Context instead, the tooling automatically tries to run the routing context against a supplied JUnit test. Because a JUnit test does not exist, the tooling reverts to running the routing context without tests. In the Chapter 9, Testing a route with JUnit tutorial, you create a JUnit test case to test the ZooOrderApp project.

    The Console panel opens to display log messages that reflect the progress of the project’s execution. At the beginning, Maven downloads the resources necessary to update the local Maven repository. The Maven download process can take a few minutes.

  4. Wait for messages (similar to the following) to appear at the end of the output. These messages indicate that the route executed successfully:

    ...
    [Blueprint Event Dispatcher: 1] BlueprintCamelContext INFO  Route: _route1 started and consuming from:Endpoint[file://src/data?noop=true]
    [Blueprint Event Dispatcher: 1] BlueprintCamelContext INFO  Total 1 routes, of which 1 are started.
    [Blueprint Event Dispatcher: 1]BlueprintCamelContext INFO  Apache Camel 2.21.0.redhat-3 (CamelContext: ...) started in 0.163 seconds
    [Blueprint Event Dispatcher: 1] BlueprintCamelContext INFO  Apache Camel 2.21.0.redhat-3 (CamelContext: ...) started in 0.918 seconds
  5. To shutdown the route, click console’s shutdown button located at the top of the Console view.

Verifying the route

To verify that the route executed properly, you check to see whether the message XML files were copied from the source folder (src/data) to the target folder (target/messages/received).

  1. In Project Explorer, select ZooOrderApp.
  2. Right-click and then select Refresh.
  3. In Project Explorer, locate the target/messages/ folder and expand it to verify that the target/messages/received folder contains the six message files, message1.xml through message6.xml:

    message destination
  4. Double-click message1.xml to open it in the route editor’s Design tab, and then select the Source tab to see the XML code:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <order>
      <customer>
        <name>Bronx Zoo</name>
        <city>Bronx NY</city>
        <country>USA</country>
      </customer>
      <orderline>
        <animal>wombat</animal>
        <quantity>12</quantity>
      </orderline>
    </order>

Next steps

In the Chapter 5, Adding a Content-Based Router tutorial you add a Content-Based Router that uses the content of a message to determine its destination.

Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

© 2024 Red Hat, Inc.