3.6. 開発モードでの Camel K インテグレーションの実行


開発モードの Camel K インテグレーションは、コマンドラインから OpenShift クラスターで実行できます。開発モードを使用すると、開発段階にてインテグレーションで繰り返しを迅速に行うことができ、コードに関するフィードバックを即座に受け取ることができます。

--dev オプションを指定して kamel run コマンドを実行すると、インテグレーションがクラウドで即座にデプロイされ、ターミナルにインテグレーションログが表示されます。次に、コードを変更でき、変更が自動的かつ即座に OpenShift のリモートインテグレーション Pod に適用されることを確認できます。ターミナルには、クラウドのリモートインテグレーションの再デプロイメントすべてが自動的に表示されます。

注記

開発モードで Camel K によって生成されたアーティファクトは、実稼働環境で実行するアーティファクトと同じです。開発モードの目的は、より迅速な開発を行うことです。

前提条件

手順

  1. 以下の例のように、oc クライアントツールを使用して OpenShift クラスターにログインします。

    $ oc login --token=my-token --server=https://my-cluster.example.com:6443
    Copy to Clipboard Toggle word wrap
  2. 以下の例のように、Camel K Operator が稼働していることを確認します。

    $ oc get pod
    NAME                               READY   STATUS    RESTARTS   AGE
    camel-k-operator-86b8d94b4-pk7d6   1/1     Running   0          6m28s
    Copy to Clipboard Toggle word wrap
  3. kamel run コマンドと --dev を入力し、クラウドの OpenShift にて開発モードでインテグレーションを実行します。以下は、簡単な Java の例になります。

    $ kamel run HelloCamelK.java --dev
    integration "hello-camel-k" created
    Progress: integration "hello-camel-k" in phase Initialization
    Progress: integration "hello-camel-k" in phase Building Kit
    Progress: integration "hello-camel-k" in phase Deploying
    Progress: integration "hello-camel-k" in phase Running
    IntegrationPlatformAvailable for Integration hello-camel-k: camel-k
    Integration hello-camel-k in phase Initialization
    No IntegrationKitAvailable for Integration hello-camel-k: creating a new integration kit
    Integration hello-camel-k in phase Building Kit
    IntegrationKitAvailable for Integration hello-camel-k: kit-bq8t5cudeam3u3sj13tg
    Integration hello-camel-k in phase Deploying
    No CronJobAvailable for Integration hello-camel-k: different controller strategy used (deployment)
    DeploymentAvailable for Integration hello-camel-k: deployment name is hello-camel-k
    No ServiceAvailable for Integration hello-camel-k: no http service required
    No ExposureAvailable for Integration hello-camel-k: no target service found
    Integration hello-camel-k in phase Running
    [2] Monitoring pod hello-camel-k-866ccb5976-sjh8x[1] Monitoring pod hello-camel-k-866ccb5976-l288p[2] 2020-04-11 14:44:53.691 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.ContextConfigurer@159f197
    [2] 2020-04-11 14:44:53.694 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesConfigurer@1f0f1111
    [2] 2020-04-11 14:44:53.695 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesDumper@6e0dec4a
    [2] 2020-04-11 14:44:53.695 INFO  [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.PropertiesFunctionsConfigurer@794cb805
    [2] 2020-04-11 14:44:53.712 INFO  [main] ApplicationRuntime - Listener org.apache.camel.k.listener.PropertiesFunctionsConfigurer@794cb805 executed in phase Starting
    [2] 2020-04-11 14:44:53.721 INFO  [main] RuntimeSupport - Looking up loader for language: java
    [2] 2020-04-11 14:44:53.723 INFO  [main] RuntimeSupport - Found loader org.apache.camel.k.loader.java.JavaSourceLoader@3911c2a7 for language java from service definition
    [2] 2020-04-11 14:44:54.220 INFO  [main] RoutesConfigurer - Loading routes from: file:/etc/camel/sources/i-source-000/HelloCamelK.java?language=java
    [2] 2020-04-11 14:44:54.220 INFO  [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesConfigurer@1f0f1111 executed in phase ConfigureRoutes
    [2] 2020-04-11 14:44:54.224 INFO  [main] BaseMainSupport - Using properties from: file:/etc/camel/conf/application.properties
    [2] 2020-04-11 14:44:54.385 INFO  [main] ApplicationRuntime - Listener org.apache.camel.k.listener.ContextConfigurer@159f197 executed in phase ConfigureContext
    [2] 2020-04-11 14:44:54.386 INFO  [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) is starting
    [2] 2020-04-11 14:44:54.387 INFO  [main] DefaultManagementStrategy - JMX is disabled
    [2] 2020-04-11 14:44:54.630 INFO  [main] DefaultCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
    [2] 2020-04-11 14:44:54.639 INFO  [main] DefaultCamelContext - Route: java started and consuming from: timer://java?period=1s
    [2] 2020-04-11 14:44:54.643 INFO  [main] DefaultCamelContext - Total 1 routes, of which 1 are started
    [2] 2020-04-11 14:44:54.643 INFO  [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in 0.258 seconds
    [2] 2020-04-11 14:44:54.644 INFO  [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started
    [2] 2020-04-11 14:44:55.671 INFO  [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K from java]
    ...
    Copy to Clipboard Toggle word wrap
  4. インテグレーション DSL ファイルの内容を編集し、変更を保存します。ターミナルで変更が即座に表示されることを確認します。以下に例を示します。

    ...
    integration "hello-camel-k" updated
    ...
    [3] 2020-04-11 14:45:06.792 INFO  [main] DefaultCamelContext - Route: java started and consuming from: timer://java?period=1s
    [3] 2020-04-11 14:45:06.795 INFO  [main] DefaultCamelContext - Total 1 routes, of which 1 are started
    [3] 2020-04-11 14:45:06.796 INFO  [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in 0.323 seconds
    [3] 2020-04-11 14:45:06.796 INFO  [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started
    [3] 2020-04-11 14:45:07.826 INFO  [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Ciao Camel K from java]
    ...
    Copy to Clipboard Toggle word wrap
  5. Ctrl-C キーを押して、ターミナルでログインを終了します。

関連情報

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

Theme

© 2025 Red Hat