8.2. Camel Quarkus アプリケーションの例の実装
この例では、簡単な 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")); } }- この例では、Camel ルートを介してコンテナーログの "Hello Camel …" エントリーをログに記録します。
次のプロパティーを使用して
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 = 10000pom.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>