Red Hat Camel K is deprecated
Red Hat Camel K is deprecated and the End of Life date for this product is June 30, 2025. For help migrating to the current go-to solution, Red Hat build of Apache Camel, see the Migration Guide.41.3. 使用方法
このセクションでは、jslt-action
の使用方法を説明します。
41.3.1. Knative Action
jslt-action
Kamelet を Knative バインドの中間ステップとして使用できます。
jslt-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: jslt-action-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: timer-source properties: message: {"foo" : "bar"} steps: - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: jslt-action properties: template: "file://template.json" sink: ref: kind: Channel apiVersion: messaging.knative.dev/v1 name: mychannel
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: jslt-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: {"foo" : "bar"}
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: jslt-action
properties:
template: "file://template.json"
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
41.3.1.1. 前提条件
接続先の OpenShift クラスターに "Red Hat Integration - Camel K" がインストールされていることを確認します。
41.3.1.2. クラスター CLI の使用手順
-
jslt-action-binding.yaml
ファイルをローカルドライブに保存し、設定の必要に応じて編集します。 以下のコマンドを使用して、アクションを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f jslt-action-binding.yaml
oc apply -f jslt-action-binding.yaml
41.3.1.3. Kamel CLI を使用するための手順
以下のコマンドを使用して、アクションを設定および実行します。
kamel bind timer-source?message=Hello --step jslt-action -p "step-0.template=file://template.json" channel:mychannel
kamel bind timer-source?message=Hello --step jslt-action -p "step-0.template=file://template.json" channel:mychannel
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。
テンプレートが現在のディレクトリーにないファイルを指している場合、および file://
または classpath://
が使用されている場合は、シークレットまたは configmap を使用して変換を提供します。
例を表示するには、with secret および with configmap を参照してください。必要なトレイトの詳細は、Mount トレイト および JVM クラスパストレイト を参照してください。
41.3.2. Kafka Action
jslt-action
Kamelet を Kafka バインドの中間ステップとして使用できます。
jslt-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: jslt-action-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: timer-source properties: message: {"foo" : "bar"} steps: - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: jslt-action properties: template: "file://template.json" sink: ref: kind: KafkaTopic apiVersion: kafka.strimzi.io/v1beta1 name: my-topic
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: jslt-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: {"foo" : "bar"}
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: jslt-action
properties:
template: "file://template.json"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
41.3.2.1. 前提条件
OpenShift クラスターに AMQ Streams Operator がインストールされていることを確認し、現在の namespace に my-topic
という名前のトピックを作成します。また、接続先の OpenShift クラスターに "Red Hat Integration - Camel K" がインストールされている必要があります。
41.3.2.2. クラスター CLI の使用手順
-
jslt-action-binding.yaml
ファイルをローカルドライブに保存し、設定の必要に応じて編集します。 以下のコマンドを使用して、アクションを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f jslt-action-binding.yaml
oc apply -f jslt-action-binding.yaml
41.3.2.3. Kamel CLI を使用するための手順
以下のコマンドを使用して、アクションを設定および実行します。
kamel bind timer-source?message=Hello --step jslt-action -p "step-0.template=file://template.json" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
kamel bind timer-source?message=Hello --step jslt-action -p "step-0.template=file://template.json" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。