2.2. Blueprint XML DSL ルートの移行


Blueprint XML ルート定義を Fuse アプリケーションから CEQ に移行するには、camel-quarkus-xml-io-dsl エクステンションを使用し、Fuse アプリケーションのルート定義を CEQ アプリケーションに直接コピーします。次に、必要な依存関係を CEQ pom.xml ファイルに追加し、application.properties ファイル内の CEQ 設定を更新する必要があります。

注記

CEQ は Camel 3 をサポートしますが、Fuse 7 は Camel 2 をサポートします。

Red Hat Fuse 7 アプリケーションを CEQ に移行する際の Camel のアップグレードに関する詳細は、Apache Camel の移行 を参照してください。

Camel Quarkus での Bean の使用の詳細は、Red Hat build of Apache Camel for Quarkus を使用したアプリケーションの開発 ガイドの CDI および Camel Bean コンポーネント セクションを参照してください。

2.2.1. XML-IO-DSL の制限事項

camel-quarkus-xml-io-dsl エクステンションを使用すると、Blueprint XML ルート定義の CEQ への移行を支援できます。

camel-quarkus-xml-io-dsl エクステンションは、次の <camelContext> サブ要素のみをサポートします。

  • routeTemplates
  • templatedRoutes
  • rests
  • routes
  • routeConfigurations
注記

Blueprint XML は camel-quarkus-xml-io-dsl エクステンションでサポートされていない他の Bean 定義をサポートしているため、Blueprint XML ルート定義に含まれる他の Bean 定義を書き直す必要が生じる場合があります。

すべての要素 (XML IO DSL) をそれぞれ別のファイルで定義する必要があります。たとえば、これは Blueprint XML ルート定義の簡単な例です。

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <restConfiguration contextPath="/camel" />
        <rest path="/books">
            <get uri="/">
                <to ..../>
            </get>
        </rest>
        <route>
            <from ..../>
        </route>
    </camelContext>
</blueprint>
Copy to Clipboard Toggle word wrap

次のファイルで定義されているように、XML IO DSL を使用して、この Blueprint XML ルート定義を CEQ に移行できます。

src/main/resources/routes/camel-rests.xml

<rests xmlns="http://camel.apache.org/schema/spring">
    <rest path="/books">
    <get path="/">
        <to ..../>
    </get>
    </rest>
</rests>
Copy to Clipboard Toggle word wrap

src/main/resources/routes/camel-routes.xml

<routes xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from ..../>
    </route>
</routes>
Copy to Clipboard Toggle word wrap

<restConfiguration> など、サポートされていない他の要素を定義するには、Java DSL を使用する必要があります。たとえば、次のように、camel-rests.xml ファイルで定義されたルートビルダーを使用します。

src/main/resources/routes/camel-rests.xml

import org.apache.camel.builder.RouteBuilder;
public class Routes extends RouteBuilder {
    public void configure() {
       restConfiguration()
            .contextPath("/camel");
    }
}
Copy to Clipboard Toggle word wrap

2.2.2. Blueprint XML DSL ルート移行の例

注記

XML IO DSL エクステンションの使用に関する詳細は、「Red Hat build of Apache Camel for Quarkus エクステンション」の XML IO DSL ドキュメントを参照してください。

この例では、Blueprint XML ルート定義を CEQ アプリケーションの camel-routes.xml という名前のファイルにコピーして、Fuse アプリケーションから新しい CEQ アプリケーションにコンテンツベースのルート定義を移行しています。

手順

  1. Web サイト code.quarkus.redhat.com を使用して、この例で使用する次のエクステンションを選択します。

    • camel-quarkus-xml-io-dsl
    • camel-quarkus-file
    • camel-quarkus-xpath
  2. Generate your application を選択して選択内容を確認し、生成されたプロジェクトを含むアーカイブのダウンロードリンクが記載されたオーバーレイ画面を表示します。
  3. Download the ZIP を選択して、生成されたプロジェクトファイルを含むアーカイブをマシンに保存します。
  4. アーカイブの内容をデプロイメントします。
  5. 直前の手順で生成されたプロジェクトファイルの展開先ディレクトリーに移動します。

    $ cd <directory_name>
    Copy to Clipboard Toggle word wrap
  6. src/main/resources/routes/ ディレクトリーに camel-routes.xml という名前のファイルを作成します。
  7. 次の例 blueprint-example.xml<route> 要素とサブ要素を camel-routes.xml ファイルにコピーします。

    blueprint-example.xml

    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
        <camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/blueprint">
            <route id="cbr-route">
                <from id="_from1" uri="file:work/cbr/input"/>
                <log id="_log1" message="Receiving order ${file:name}"/>
                <choice id="_choice1">
                    <when id="_when1">
                        <xpath id="_xpath1">/order/customer/country = 'UK'</xpath>
                        <log id="_log2" message="Sending order ${file:name} to the UK"/>
                        <to id="_to1" uri="file:work/cbr/output/uk"/>
                    </when>
                    <when id="_when2">
                        <xpath id="_xpath2">/order/customer/country = 'US'</xpath>
                        <log id="_log3" message="Sending order ${file:name} to the US"/>
                        <to id="_to2" uri="file:work/cbr/output/us"/>
                    </when>
                    <otherwise id="_otherwise1">
                        <log id="_log4" message="Sending order ${file:name} to another country"/>
                        <to id="_to3" uri="file:work/cbr/output/others"/>
                    </otherwise>
                </choice>
                <log id="_log5" message="Done processing ${file:name}"/>
            </route>
        </camelContext>
    </blueprint>
    Copy to Clipboard Toggle word wrap

    camel-routes.xml

    <route id="cbr-route">
        <from id="_from1" uri="file:work/cbr/input"/>
        <log id="_log1" message="Receiving order ${file:name}"/>
        <choice id="_choice1">
            <when id="_when1">
                <xpath id="_xpath1">/order/customer/country = 'UK'</xpath>
                <log id="_log2" message="Sending order ${file:name} to the UK"/>
                <to id="_to1" uri="file:work/cbr/output/uk"/>
            </when>
            <when id="_when2">
                <xpath id="_xpath2">/order/customer/country = 'US'</xpath>
                <log id="_log3" message="Sending order ${file:name} to the US"/>
                <to id="_to2" uri="file:work/cbr/output/us"/>
            </when>
            <otherwise id="_otherwise1">
                <log id="_log4" message="Sending order ${file:name} to another country"/>
                <to id="_to3" uri="file:work/cbr/output/others"/>
            </otherwise>
        </choice>
        <log id="_log5" message="Done processing ${file:name}"/>
    </route>
    Copy to Clipboard Toggle word wrap

  8. application.properties を修正します。

    # Camel
    #
    camel.context.name = camel-quarkus-xml-io-dsl-example
    camel.main.routes-include-pattern = file:src/main/resources/routes/camel-routes.xml
    Copy to Clipboard Toggle word wrap
  9. CEQ アプリケーションをコンパイルします。

    mvn clean compile quarkus:dev
    Copy to Clipboard Toggle word wrap
    注記

    このコマンドでは、プロジェクトのコンパイル、アプリケーションの起動、Quarkus ツールでのワークスペースの変更監視などを行います。プロジェクトの変更は自動的に実行中のアプリケーションに適用されます。

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る