8.2. Camel Quarkus アプリケーションの例の実装


  1. この例では、簡単な Camel ‘hello-world’ Quarkus アプリケーションを実装します。src/main/java/org/hawtio/SampleCamelRoute.java ファイルを以下の内容のプロジェクトに追加します。

    package org.hawtio;
    
    import jakarta.enterprise.context.ApplicationScoped;
    import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
    
    @ApplicationScoped
    public class SampleCamelRoute extends EndpointRouteBuilder
    {
    
    	@Override
    	public void configure()
    	{
    		from(quartz("cron").cron("{{quartz.cron}}")).routeId("cron")
    			.setBody().constant("Hello Camel! - cron")
    			.to(stream("out"))
    			.to(mock("result"));
    
         	from("quartz:simple?trigger.repeatInterval={{quartz.repeatInterval}}").routeId("simple")
    			.setBody().constant("Hello Camel! - simple")
    			.to(stream("out"))
    			.to(mock("result"));
    	}
    }
    1. この例では、Camel ルートを介してコンテナーログの "Hello Camel …​" エントリーをログに記録します。
  2. 次のプロパティーを使用して src/main/resources/application.properties ファイルを変更します。

      # Camel
      camel.context.name = SampleCamel
    
      # Uncomment the following to enable the Camel plugin Trace tab
      #camel.main.tracing = true
      #camel.main.backlogTracing = true
      #camel.main.useBreadcrumb = true
    
      # Uncomment to enable debugging of the application and in turn
      # enables the Camel plugin Debug tab even in non-development
      # environment
      #quarkus.camel.debug.enabled = true
    
      # Define properties for the Camel quartz component used in the
      # example
      quartz.cron = 0/10 * * * * ?
      quartz.repeatInterval = 10000
  3. pom.xml ファイルの <dependencies> セクションに次の依存関係を追加します。これらは src/main/java/org/hawtio/SampleCamelRoute.java で定義されているルートのために必要です。アプリケーションに追加された Camel ルートが変更された場合は、これらを変更する必要があります。

    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-stream</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-mock</artifactId>
    </dependency>
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

Theme

© 2026 Red Hat
トップに戻る