검색

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

Chapter 3. Defining a Route

download PDF

This tutorial walks you through adding and configuring endpoints to a route. Endpoints define the source and sink for messages traveling through the route. For your ZooOrderApp project, the starting (source) endpoint is the folder containing the XML message files. The sink (finishing) endpoint is another folder that you specify in your project.

Goals

In this tutorial you complete the following tasks:

  • Add source and sink endpoints to the route
  • Configure the endpoints
  • Connect the endpoints

Before you begin

Before you start this tutorial:

  1. You must set up your workspace environment, as described in the Chapter 2, Setting up your environment tutorial.
  2. In CodeReady Studio, open your ZooOrderApp project’s /src/main/resources/OSGI-INF/blueprint/blueprint.xml file in the Editor view.
  3. If needed, click the Design tab at the bottom of the Editor view to see the graphic display of the initial route, labeled Route_route1.

Configuring the source endpoint

Follow these steps to configure the src/data folder as the route’s source endpoint:

  1. Drag a File component ( File icon ) from the Palette's Components drawer to the canvas, and drop it in the Route_route1 container node.

    The File component changes to a From _from1 node inside the Route_route1 container node.

  2. On the canvas, select the From _from1 node.

    The Properties view, located below the canvas, displays the node’s property fields for editing.

  3. To specify the source directory for the message files, in the Properties view, click the Advanced tab:

    FileSysCompProps1Tut
  4. In the Directory Name field, enter src/data:

    FileSystemCompPropsTut

    The path src/data is relative to the project’s directory.

  5. On the Consumer tab, enable the Noop option by clicking its check box.

    The Noop option prevents the message#.xml files from being deleted from the src/data folder, and it enables idempotency to ensure that each message#.xml file is consumed only once.

  6. Select the Details tab to open the file node’s Details page.

    Notice that the tooling automatically populates the Uri field with the Directory Name and Noop properties you configured on the Advanced tab. It also populates the Id field with an autogenerated ID (_from1):

    FileSystemCompPropsTut2
    Note

    The tooling prefixes autogenerated ID values with an underscore (_). You can optionally change the ID value. The underscore prefix is not a requirement.

    Leave the autogenerated Id as is.

  7. Select File Save to save the route.

Configuring the sink endpoint

To add and configure the route’s sink (target) endpoint:

  1. Drag another File component from the Palette's Components drawer and drop it in the Route_route1 container node.

    The File component changes to a To_to1 node inside the Route_route1 container node.

  2. On the canvas, select the To_to1 node.

    The Properties view, located below the canvas, displays the node’s property fields for editing.

  3. On the Details tab:

    1. In the Uri field, type file:target/messages/received.
    2. In the Id field, type _Received.

      FilesysTargetCompPropsTut
      Note

      The tooling will create the target/messages/received folder at runtime.

  4. In the Route_route1 container, select the From _from1 node and drag its connector arrow ( connector arrow icon ) over the To_Received node, and then release it:

    CompletedRoute1
    Note

    The two file nodes are connected and aligned on the canvas according to the route editor’s layout direction preference setting. The choices are Down (the default) and Right.

    To access the route editor 's layout preference options:

    • On Linux and Windows machines, select Windows Preferences Fuse Tooling Editor Choose the layout direction for the diagram editor.
    • On OS X, select CodeReady Studio Preferences Fuse Tooling Editor Choose the layout direction for the diagram editor.
    Note

    If you do not connect the nodes before you close the project, the tooling automatically connects them when you reopen it.

  5. Save the route.
  6. Click the Source tab at the bottom of the canvas to display the XML for the route:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
        https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
        http://camel.apache.org/schema/blueprint
        http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    
        <camelContext id="_context1" xmlns="http://camel.apache.org/schema/blueprint">
            <route id="_route1">
                <from id="_from1" uri="file:src/data?noop=true"/>
                <to id="_Received" uri="file:target/messages/received"/>
            </route>
        </camelContext>
    </blueprint>

Next steps

Now that you have added and configured endpoints in the route, you can run the route as described in the Chapter 4, Running a Route tutorial.

Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

© 2024 Red Hat, Inc.