第1章 Red Hat build of Apache Camel for Spring Boot のスタートガイド


このガイドでは、Red Hat build of Apache Camel for Spring Boot を紹介し、Red Hat build of Apache Camel for Spring Boot を使用してアプリケーションの構築を開始する方法を示します。

1.1. Red Hat build of Apache Camel for Spring Boot のスターター

Spring Boot の Camel サポートは、Camel の自動設定と多くの Camel コンポーネント のスターターを提供します。Camel コンテキストの独自の自動設定は、Spring コンテキストで使用可能な Camel ルートを自動検出し、主要な Camel ユーティリティー (プロデューサーテンプレート、コンシューマーテンプレート、型コンバーターなど) を Bean として登録します。

注記

Maven アーキタイプを使用して Camel for Spring Boot アプリケーションを生成する方法については、Maven を使用した Spring Boot アプリケーション用の Camel 生成 を参照してください。

まず、Camel Spring Boot BOM を Maven pom.xml ファイルに追加する必要があります。

<dependencyManagement>

    <dependencies>
        <!-- Camel BOM -->
        <dependency>
            <groupId>com.redhat.camel.springboot.platform</groupId>
            <artifactId>camel-spring-boot-bom</artifactId>
            <version>4.0.0.redhat-00039</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- ... other BOMs or dependencies ... -->
    </dependencies>

</dependencyManagement>
Copy to Clipboard Toggle word wrap

camel-spring-boot-bom は、Camel Spring Boot スターター JAR のリストを含む基本的な BOM です。

次に、Camel Spring Boot スターター を追加して Camel Context を起動します。

    <dependencies>
        <!-- Camel Starter -->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
        </dependency>
        <!-- ... other dependencies ... -->
    </dependencies>
Copy to Clipboard Toggle word wrap

Spring Boot アプリケーションに必要な コンポーネントスターター も追加する必要があります。次の例は、自動設定スターターMQTT5 コンポーネント に追加する方法を示しています。

    <dependencies>
        <!-- ... other dependencies ... -->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-paho-mqtt5</artifactId>
        </dependency>
    </dependencies>
Copy to Clipboard Toggle word wrap

1.1.1. Camel Spring Boot BOM と Camel Spring Boot の依存関係 BOM

生成されるキュレートされた camel-spring-boot-dependencies BOM には、Spring Boot と Apache Camel の両方が競合を回避するために使用する調整された JAR が含まれています。この BOM は camel-spring-boot 自体をテストするために使用されます。

Spring Boot ユーザーは、管理対象の依存関係として Camel スターター JAR のみを持つ camel-spring-boot-bom を使用して、純粋な Camel 依存関係を使用することもできます。ただし、Spring Boot のサードパーティー JAR が特定の Camel コンポーネントと互換性がない場合、クラスパスの競合が発生する可能性があります。

1.1.2. Spring Boot 設定のサポート

スターター には、標準の application.properties または application.yml ファイルで設定できる設定パラメーターがリストされています。これらのパラメーターの形式は camel.component.[component-name].[parameter] です。たとえば、MQTT5 ブローカーの URL を設定するには、次のように設定できます。

camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
Copy to Clipboard Toggle word wrap

1.1.3. Camel ルートの追加

Camel ルート は Spring アプリケーションコンテキストで検出されます。たとえば、org.springframework.stereotype.Component でアノテーションが付けられたルートがロードされ、Camel コンテキストに追加されて実行されます。

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class MyRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("...")
            .to("...");
    }

}
Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

Theme

© 2026 Red Hat