Camel Extensions for Quarkus と Camel K の入門

こんにちは、ソリューションアーキテクトの蒸野(ムシノ)です。

これまで Apache Camel や Red Hat Fuse のご紹介をしてきました。
今回は本シリーズ最後となります、Apache Camelをベースとした製品ファミリの「Camel Extensions for Quarkus」と「Camel K」をご紹介したいと思います。

前回までの振り返り

rheb.hatenablog.com

rheb.hatenablog.com

Apache Camel 製品ファミリ

Apache Camel はいくつかのサブプロジェクトに別れています。Red Hat ではこのサブプロジェクトに合せて Apache Camel 製品ファミリを構成しています。前回ご紹介した 「Fuse」も同製品ファミリに含まれており、現時点では「Fuse」「Camel Extensions for Quarkus」「Camel K」といった3製品を提供しています。

いくつかある製品ですが、大きな特徴として Apahe Camel 2 ベースとしているか、Apache Camel 3 ベースであるかといった違いがあります。その他には「Camel Extensions for Quarkus」ではスタンドアローン構成をとれますが、「Camel K」ではOpenShift上でしか動作させることができないといった制限があります。

それぞれ特徴と強みがありますので、個々にご紹介していきたいと思います。

Apache Camel 3 とは?

今回紹介する「Camel Extensions for Quarkus」と「Camel K」は、Apache Camel 3をベースにした製品になります。Apache Camel 3 については下記の記事に詳細が記載されていますので、こちらをご覧いただければと思います。 rheb.hatenablog.com

rheb.hatenablog.com

Camel Extensions for Quarkus

まず最初に「Camel Extensions for Quarkus」を紹介したいと思います。
Apache Camel では次のように説明されています。

「APACHE CAMEL EXTENSIONS FOR QUARKUS」プロジェクトは Apache Camel とその膨大なコンポーネントライブラリの統合機能を、Quarkusランタイムにもたらすことを目的としています。これにより、ユーザーはQuarkusが提供するパフォーマンスの利点、developer joy、コンテナファーストの理念を利用することができます。

製品ガイドでは、「Camel Extensions for Quarkus は、Apache Camel とその vast コンポーネントライブラリーの統合機能を Quarkus ランタイムに提供します。」とあります。同じような説明は省くとして、Apache Camel コンポーネントにも Quarkus エクステンションを提供している点や、Camel 3 でパフォーマンスが向上している点、メモリーフットプリントが少なくなり高速に動作し、かつ起動時間が短縮されるといった点がメリットと言えるでしょう。また、Camel Extensions for Quarkusでは、Red Hat Enterprise Linux 上でも、OpenShift 上でも動作させることができます。

access.redhat.com

Camel Extensions for Quarkus の始め方

それでは最初の一歩として、製品ガイドにある「Camel Extensions for Quarkus を使用した最初のプロジェクトのビルド」 をやってみたいと思います。

1.スケルトンアプリケーションの生成

まずはスケルトンアプリケーションを取得するために、下記にアクセスして頂きます。
https://code.quarkus.redhat.com/

下記のような画面が表示されるかと思います。

2. Extensions を選択

次に、下記2つの Extensions を選択します。

  • camel-quarkus-rest
  • camel-quarkus-jackson

それぞれ、Extensions の Filters で検索し、チェックボックスにチェックを入れます。

Extensions を2つとも選択できたら右のメニューからスケルトンアプリケーションをダウンロードします。

3. スケルトンアプリケーションの確認

任意の場所でダウンロードしたZIPファイルを解凍します。
スケルトンアプリケーションのディレクトリは次にようになっているかと思います。

ls
README.md       mvnw*           mvnw.cmd*       pom.xml         src/

4. Camel ルートを追加する

簡単な Camel ルートを追加してみたいと思います。
src/main/java/org/acme 以下に Routes.java という名前で作成します。

cd code-with-quarkus/src/main/java/org/acme
❯ vi Routes.java

Routes.java は次のようにシンプルなコードとなっています。これを追加します。

package org.acme;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;

import io.quarkus.runtime.annotations.RegisterForReflection;

public class Routes extends RouteBuilder {
    private final List<Fruit> fruits = new CopyOnWriteArrayList<>(Arrays.asList(new Fruit("Apple")));

    @Override
    public void configure() throws Exception {
        restConfiguration().bindingMode(RestBindingMode.json);

        rest("/fruits")
                .get()
                .route()
                .setBody(e -> fruits)
                .endRest()

                .post()
                .type(Fruit.class)
                .route()
                .process().body(Fruit.class, (Fruit f) -> fruits.add(f))
                .endRest();

    }

    @RegisterForReflection // Let Quarkus register this class for reflection during the native build
    public static class Fruit {
        private String name;

        public Fruit() {
        }

        public Fruit(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public int hashCode() {
            return Objects.hash(name);
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Fruit other = (Fruit) obj;
            return Objects.equals(name, other.name);
        }
    }
}

5. 開発者モードでの実行

それでは一度、開発者モードで実行してみたいと思います。
最初の起動はライブラリなどをダウンロードするので数分待ちますが、次回からは数秒で起動します。

❯ mvn clean compile quarkus:dev

・・・(省略)

__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2022-06-23 19:01:40,541 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (Quarkus Main Thread) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime

2022-06-23 19:01:40,730 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Routes startup (total:2 started:2)
2022-06-23 19:01:40,730 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread)     Started route1 (rest://get:/fruits)
2022-06-23 19:01:40,731 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread)     Started route2 (rest://post:/fruits)
2022-06-23 19:01:40,731 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Apache Camel 3.14.1 (camel-1) started in 132ms (build:0ms init:82ms start:50ms)
2022-06-23 19:01:40,848 INFO  [io.quarkus] (Quarkus Main Thread) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.7.5.Final-redhat-00011) started in 2.043s. Listening on: http://localhost:8080
2022-06-23 19:01:40,850 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2022-06-23 19:01:40,850 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [camel-attachments, camel-core, camel-jackson, camel-platform-http, camel-rest, cdi, resteasy, smallrye-context-propagation, vertx]

--
Tests paused
Press [r] to resume testing, [o] Toggle test output, [:] for the terminal, [h] for more options>

6. 実行結果の確認

Curlにて動作確認を行います。下記のように「Apple」と表示されていれば正常にインテグレーションができています。

❯ curl http://localhost:8080/fruits
[{"name":"Apple"}]

7. インテグレーションアプリケーションのパッケージング

MVNコマンドでカスタマイズしたスケルトンアプリケーションをパッケージングします。

❯ mvn -DskipTests=true clean package 

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ code-with-quarkus ---
[INFO] Deleting /////camel-extension-for-quarkus/code-with-quarkus/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ code-with-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- quarkus-maven-plugin:2.7.5.Final-redhat-00011:generate-code (default) @ code-with-quarkus ---
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ code-with-quarkus ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /////camel-extension-for-quarkus/code-with-quarkus/target/classes
[INFO] 
[INFO] --- quarkus-maven-plugin:2.7.5.Final-redhat-00011:generate-code-tests (default) @ code-with-quarkus ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ code-with-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /////camel-extension-for-quarkus/code-with-quarkus/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ code-with-quarkus ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /////camel-extension-for-quarkus/code-with-quarkus/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ code-with-quarkus ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ code-with-quarkus ---
[INFO] Building jar: /////camel-extension-for-quarkus/code-with-quarkus/target/code-with-quarkus-1.0.0-SNAPSHOT.jar
[INFO] 
[INFO] --- quarkus-maven-plugin:2.7.5.Final-redhat-00011:build (default) @ code-with-quarkus ---
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 1728ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.271 s
[INFO] Finished at: 2022-06-23T19:18:41+09:00
[INFO] ------------------------------------------------------------------------

target/quarkus-appディレクトリ配下に「quarkus-run.jar 」が作成されています。
これを実行します。

❯ java -jar quarkus-run.jar
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2022-06-23 19:33:09,192 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
2022-06-23 19:33:09,588 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (total:2 started:2)
2022-06-23 19:33:09,589 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (rest://get:/fruits)
2022-06-23 19:33:09,589 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route2 (rest://post:/fruits)
2022-06-23 19:33:09,589 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.14.1 (camel-1) started in 269ms (build:0ms init:115ms start:154ms)
2022-06-23 19:33:09,767 INFO  [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.7.5.Final-redhat-00011) started in 1.899s. Listening on: http://0.0.0.0:8080
2022-06-23 19:33:09,767 INFO  [io.quarkus] (main) Profile prod activated. 
2022-06-23 19:33:09,768 INFO  [io.quarkus] (main) Installed features: [camel-attachments, camel-core, camel-jackson, camel-platform-http, camel-rest, cdi, resteasy, smallrye-context-propagation, vertx]

実行環境によりますが、1秒〜数秒ほどで起動します。高速に起動・動作することを実感してもらえるかと思います。

8. 実行結果の確認

もう一度先程と同様で、Curlにて動作確認を行います。

❯ curl http://localhost:8080/fruits
[{"name":"Apple"}]

Camel K

次に、「Camel K」を紹介したいと思います。
Apache Camel では次のように説明されています。

Apache Camel Kは、Kubernetes上でネイティブに動作するApache Camelをベースにした軽量な統合フレームワークで、特にサーバーレスやマイクロサービスアーキテクチャのために設計されています。Camel DSLで書かれた統合コードをクラウド上で実行することができます。

製品ガイドでは、「Red Hat Integration - Camel Kは、OpenShift上でネイティブに動作するApache Camel K からビルドされる軽量のインテグレーションフレームワークです。」と説明しています。ここでも同じような説明は省いて少し補足します。Camel K はgo言語 で実装されサーバーレスおよびマイクロサービスアーキテクチャー向けに設計されています。また、Kubernetes Operator を使用して OpenShift にデプロイでき、起動時間はかなり早く、数秒以内でサービスが立ち上がることで軽量なインテグレーションフレームワークとして利用することができます。

access.redhat.com

Camel K については下記記事でも詳細に説明がなされています。是非ご覧いただけたらと思います。 rheb.hatenablog.com

Camel K の始め方

事前準備

それでは最初の一歩として、製品ガイドにある、「基本的な Camel K Java インテグレーションのデプロイ 」をやってみたいと思います。 しかしその前に Camel K ではいくつか準備が必要になります。

まず、Camel K はOpenShift上でしか動作しません。そのため、動作させるためにまずはOpenShift環境を準備する必要があります。

Redhat オンラインLAB(OPEN)環境で試したいと思います。
オンラインLAB(OPENTLC) 利用方法については下記記事をご覧ください。
レッドハットのパートナー【5】Red Hat OPEN に関する説明と利用手順 その2 - 赤帽エンジニアブログ

次にシンプルなCamel K のサンプルを実行させる為、デプロイ等を行うための OpenShift CLI、CamelK CLIが必要になります。そのため、下記URLを参考にそれぞれCLIをインストールします。
2.3. Camel K および OpenShift コマンドラインツールのインストール Red Hat Integration 2021.q1 | Red Hat Customer Portal

それでは、ようやく準備が整いましたので、Camel K を実行してみたいと思います。

1.Gitリポジトリのクローン

シンプルなサンプルアプリケーションを入手するため、Gitリポジトリからサンプルコードを入手します。

git clone https://github.com/openshift-integration/camel-k-example-basic.git

2.CLI環境の確認

次に事前準備で行ったCLIコマンドの確認を行います。ここで問題があると次に進めない為、コマンドが実行できない場合には事前準備を参考に再インストールを行います。

❯ oc
OpenShift Client

This client helps you develop, build, deploy, and run your applications on any
OpenShift or Kubernetes cluster. It also includes the administrative
commands for managing a cluster under the 'adm' subcommand.

To familiarize yourself with OpenShift, login to your cluster and try creating a sample application:

    oc login mycluster.mycompany.com
    oc new-project my-example
    oc new-app django-psql-example
    oc logs -f bc/django-psql-example

・・・(省略)

❯ kamel
Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless
superpowers.

Usage:
  kamel [command]

Available Commands:
  bind        Bind Kubernetes resources, such as Kamelets, in an integration flow. Endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name" or plain Camel URIs.
  completion  Generate completion scripts
  debug       Debug an integration running on Kubernetes
  delete      Delete integrations deployed on Kubernetes
  describe    Describe a resource
  dump        Dump the state of namespace
  get         Get integrations deployed on Kubernetes
  help        Help about any command
  init        Initialize empty Camel K files
  install     Install Camel K on a Kubernetes cluster
  kamelet     Configure a Kamelet
  kit         Configure an Integration Kit
  local       Perform integration actions locally.
  log         Print the logs of an integration
  rebuild     Clear the state of integrations to rebuild them
  reset       Reset the Camel K installation
  run         Run a integration on Kubernetes
  uninstall   Uninstall Camel K from a Kubernetes cluster
  version     Display client version

・・・(省略)

3.OpenShiftへプロジェクトの作成

次も事前準備に関する確認になります。事前に用意したOpenShift環境にログインを行います。

❯ oc login -u xxxxxx -p xxxxxx

ログインできたら、次は CamelK を動作させるプロジェクトを OpenShift 上に作成します。これは OpenShift のコンソール上から実施します。「camel-basic」というプロジェクトを作成します。

その後、作成した「camel-basic」プロジェクトに遷移します。

❯ oc project camel-basic
Now using project "camel-basic" on server "https://api.cluster-xxxxxxxxxxx.xxxxxxxxxx.opentlc.com:XXXX".

4.Camel K オペレータの準備

Camel K オペレータをインストールするため、OpenShiftのコンソール上から「Operator>Operator Hub」にアクセスします。 Camelと検索項目に入力すると対象オペレータが表示されますので、「Red Hat Integration - Camel K」を選択します。

Operator Hub

「Red Hat Integration - Camel K 」をインストールします。インストールする項目はすべて標準のままで大丈夫です。

Red Hat Integration - Camel K Step1

Red Hat Integration - Camel K Step2

しばらくするとインストールが完了し、オペレータが利用できるようになります。

OC コマンドでもオペレータの状況を確認しておきましょう。PHASEが「Succeeded」となっていれば問題ありません。

❯ oc get csv
NAME                              DISPLAY                         VERSION   REPLACES                          PHASE
red-hat-camel-k-operator.v1.6.7   Red Hat Integration - Camel K   1.6.7     red-hat-camel-k-operator.v1.6.6   Succeeded

5.シンプルなインテグレーションの実行

シンプルなインテグレーション例として Camel K で”Hello World...”を表示させます。今回は実行ログを表示させたい為、開発者モードで実行してみたいと思います。 では早速Cloneした「camel-k-example-basic」に移動します。「camel-k-example-basic」は下記のようになっていると思います。

ls
Basic.java             Routing.java           readme.didact.md        readme.md         routing.properties      test/

この「Basic.java」を実行させるため、一度コードを確認しておきます。見ていただいて分かるように「1秒ごとにHello World! を表示させる」ような非常にシンプルなコードです。

❯ cat Basic.java
// camel-k: language=java

import org.apache.camel.builder.RouteBuilder;

public class Basic extends RouteBuilder {
  @Override
  public void configure() throws Exception {

      from("timer:java?period=1000")
        .setHeader("example")
          .constant("Java")
        .setBody()
          .simple("Hello World! Camel K route written in ${header.example}.")
        .to("log:info");
      
  }
}

下記のように実行します。OpenShift環境によりますが、最初は数分ほどかかる場合があります。

❯ kamel run Basic.java --dev
No IntegrationPlatform resource in camel-basic namespace
Integration "basic" created
Progress: integration "basic" in phase Waiting For Platform
Condition "IntegrationPlatformAvailable" is "False" for Integration basic: openshift-operators/camel-k
Integration "basic" in phase "Waiting For Platform"
Progress: integration "basic" in phase Initialization
Condition "IntegrationPlatformAvailable" is "True" for Integration basic: openshift-operators/camel-k
Progress: integration "basic" in phase Building Kit
Integration "basic" in phase "Initialization"
Integration "basic" in phase "Building Kit"
Condition "IntegrationKitAvailable" is "False" for Integration basic: creating a new integration kit
Integration Kit "openshift-operators/kit-caqnhnuipnivars9ds5g", created by Integration "basic", changed phase to "Build Submitted"
Build "openshift-operators/kit-caqnhnuipnivars9ds5g", created by Integration "basic", changed phase to "Scheduling"
Build "openshift-operators/kit-caqnhnuipnivars9ds5g", created by Integration "basic", changed phase to "Pending"
Build "openshift-operators/kit-caqnhnuipnivars9ds5g", created by Integration "basic", changed phase to "Running"
Integration Kit "openshift-operators/kit-caqnhnuipnivars9ds5g", created by Integration "basic", changed phase to "Build Running"
・・・(省略)
[1] 2022-06-24 08:53:22,638 INFO  [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 1.9.0.fuse-800051-redhat-00001
[1] 2022-06-24 08:53:22,733 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
[1] 2022-06-24 08:53:22,924 INFO  [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='Basic', language='java', type='source', location='file:/etc/camel/sources/Basic.java', }
[1] 2022-06-24 08:53:25,521 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup summary (total:1 started:1)
[1] 2022-06-24 08:53:25,521 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (timer://java)
[1] 2022-06-24 08:53:25,521 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.11.5.fuse-800012-redhat-00004 (camel-1) started in 382ms (build:0ms init:294ms start:88ms)
[1] 2022-06-24 08:53:25,524 INFO  [io.quarkus] (main) camel-k-integration 1.6.7 on JVM (powered by Quarkus 2.2.5.Final-redhat-00010) started in 5.077s. 
[1] 2022-06-24 08:53:25,524 INFO  [io.quarkus] (main) Profile prod activated. 
[1] 2022-06-24 08:53:25,524 INFO  [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-java-joor-dsl, camel-k-core, camel-k-runtime, camel-log, camel-timer, cdi]
[1] 2022-06-24 08:53:26,526 INFO  [info] (Camel (camel-1) thread #0 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]
[1] 2022-06-24 08:53:27,521 INFO  [info] (Camel (camel-1) thread #0 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]
[1] 2022-06-24 08:53:28,520 INFO  [info] (Camel (camel-1) thread #0 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]

Podが起動するとOpenShiftのオペレータ上にあるインテグレーションタブにも実行中のインテグレーションが表示されます。実行中のインテグレーションが分かりやすく管理できます。

開発者モードでインテグレーションを停止する場合には、コマンド上から「Ctrl+c」で停止することができます。 Podも削除され、Camal K オペレータのインテグレーションからも削除されることが確認できます。

6.シンプルなインテグレーションの実行と削除

次は開発モードではなく、通常モードで実行するにはどうするか?ということですが、これは簡単です。「--dev」を付けずに実行するだけです。

❯ kamel run Basic.java
No IntegrationPlatform resource in camel-basic namespace
Integration "basic" created

実行中のログも出ません。実行中のログを確認するには「kamel log」とします。一つ注意があるとすれば、対象はソース名ではなくインテグレーションの名称である必要があります。

❯ kamel log basic
No IntegrationPlatform resource in camel-basic namespace
Integration 'basic' is now running. Showing log ...
[1] Monitoring pod basic-5b79788c6b-2dnfr
・・・(省略)
[1] 2022-06-24 09:03:12,333 INFO  [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 1.9.0.fuse-800051-redhat-00001
[1] 2022-06-24 09:03:12,429 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
[1] 2022-06-24 09:03:12,537 INFO  [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='Basic', language='java', type='source', location='file:/etc/camel/sources/Basic.java', }
[1] 2022-06-24 09:03:15,235 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup summary (total:1 started:1)
[1] 2022-06-24 09:03:15,235 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (timer://java)
[1] 2022-06-24 09:03:15,235 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.11.5.fuse-800012-redhat-00004 (camel-1) started in 306ms (build:0ms init:298ms start:8ms)
[1] 2022-06-24 09:03:15,238 INFO  [io.quarkus] (main) camel-k-integration 1.6.7 on JVM (powered by Quarkus 2.2.5.Final-redhat-00010) started in 5.094s. 
[1] 2022-06-24 09:03:15,238 INFO  [io.quarkus] (main) Profile prod activated. 
[1] 2022-06-24 09:03:15,238 INFO  [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-java-joor-dsl, camel-k-core, camel-k-runtime, camel-log, camel-timer, cdi]
[1] 2022-06-24 09:03:16,240 INFO  [info] (Camel (camel-1) thread #0 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]
[1] 2022-06-24 09:03:17,235 INFO  [info] (Camel (camel-1) thread #0 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]

さきほどはCamel K オペレータからインテグレーション状況を確認しましたが、今回はOCコマンドから確認してみましょう。同様に実行中のインテグレーションが確認できます。

❯ oc get integration
NAME    PHASE     KIT                        REPLICAS
basic   Running   kit-caqnhnuipnivars9ds5g   1

次に先程作成したインテグレーションを削除してみます。

❯ kamel delete basic
No IntegrationPlatform resource in camel-basic namespace
Integration basic deleted

そして最後にもう一度、OCコマンドで実行状況を確認します。インテグレーションが削除されたことを確認することができます。

❯ oc get integration
No resources found in camel-basic namespace.

Fuseのサポート情報

今回ご紹介させていただきました Apache Camel ベースの製品ファミリですが、Apache Camel 2 ベースの「Fuse」は徐々に「End of Life」が近づいてきています。今後は Apache Camel 3 をベースとした製品にマイグレーションいただく必要がありますので是非とも上記内容を参照頂き、余裕のあるマイグレーション計画を立てて頂けたらと思います。

access.redhat.com

マイグレーション方法としては、Apache Camel に マイグレーションガイドがありますのでまずはこちらをご参照ください。
また Red Hat からは 「MIGRATION TOOLKIT FOR APPLICATIONS」 で Camel 3 に関するルールが追加されています。マイグレーションする際には是非とも 「MIGRATION TOOLKIT FOR APPLICATIONS」 ご利用いただけたらと思います。
リリースノート Migration Toolkit for Applications 5.0 | Red Hat Customer Portal

最後に

いかがでしたでしょうか? 非常に簡単なサンプルではありましたが、Apache Camel 3 ベースの「Camel Extensions for Quarkus」と「Camel K」をご紹介させていただきました。 Quarkus によって起動や実行が早くなり、Camel K に至ってはかなり簡単にインテグレーションが実行できることご理解いただけたのではないでしょうか。

参照リンク

* 各記事は著者の見解によるものでありその所属組織を代表する公式なものではありません。その内容については非公式見解を含みます。