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.29.3. 使用方法
ここでは、insert-field-action
の使用方法について説明します。
29.3.1. Knative Action
insert-field-action
Kamelet は、Knative バインディングの中間ステップとして使用できます。
insert-field-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: insert-field-action-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: timer-source properties: message: '{"foo":"John"}' steps: - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: json-deserialize-action - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: insert-field-action properties: field: "The Field" value: "The Value" sink: ref: kind: Channel apiVersion: messaging.knative.dev/v1 name: mychannel
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: insert-field-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: '{"foo":"John"}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: json-deserialize-action
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: insert-field-action
properties:
field: "The Field"
value: "The Value"
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
29.3.1.1. 前提条件
接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
29.3.1.2. クラスター CLI の使用手順
-
insert-field-action-binding.yaml
ファイルをローカルドライブに保存し、必要に応じて設定を編集します。 以下のコマンドを使用して、アクションを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f insert-field-action-binding.yaml
oc apply -f insert-field-action-binding.yaml
29.3.1.3. Kamel CLI を使用するための手順
以下のコマンドを使用して、アクションを設定および実行します。
kamel bind --name insert-field-action-binding timer-source?message='{"foo":"John"}' --step json-deserialize-action --step insert-field-action -p step-1.field='The Field' -p step-1.value='The Value' channel:mychannel
kamel bind --name insert-field-action-binding timer-source?message='{"foo":"John"}' --step json-deserialize-action --step insert-field-action -p step-1.field='The Field' -p step-1.value='The Value' channel:mychannel
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。
29.3.2. Kafka Action
insert-field-action
Kamelet は、Kafka バインディングの中間ステップとして使用できます。
insert-field-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: insert-field-action-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: timer-source properties: message: '{"foo":"John"}' steps: - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: json-deserialize-action - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: insert-field-action properties: field: "The Field" value: "The Value" sink: ref: kind: KafkaTopic apiVersion: kafka.strimzi.io/v1beta1 name: my-topic
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: insert-field-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: '{"foo":"John"}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: json-deserialize-action
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: insert-field-action
properties:
field: "The Field"
value: "The Value"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
29.3.2.1. 前提条件
AMQ Streams Operator を OpenShift クラスターにインストールし、現在の namespace に my-topic
という名前のトピックを作成していることを確認します。接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
29.3.2.2. クラスター CLI の使用手順
-
insert-field-action-binding.yaml
ファイルをローカルドライブに保存し、必要に応じて設定を編集します。 以下のコマンドを使用して、アクションを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f insert-field-action-binding.yaml
oc apply -f insert-field-action-binding.yaml
29.3.2.3. Kamel CLI を使用するための手順
以下のコマンドを使用して、アクションを設定および実行します。
kamel bind --name insert-field-action-binding timer-source?message='{"foo":"John"}' --step json-deserialize-action --step insert-field-action -p step-1.field='The Field' -p step-1.value='The Value' kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
kamel bind --name insert-field-action-binding timer-source?message='{"foo":"John"}' --step json-deserialize-action --step insert-field-action -p step-1.field='The Field' -p step-1.value='The Value' kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。