45.3. 使用方法
ここでは、protobuf-deserialize-action の使用方法について説明します。
45.3.1. Knative Action
protobuf-deserialize-action Kamelet を Knative バインディングの中間ステップとして使用できます。
protobuf-deserialize-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: protobuf-deserialize-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: '{"first": "John", "last":"Doe"}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: json-deserialize-action
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: protobuf-serialize-action
properties:
schema: "message Person { required string first = 1; required string last = 2; }"
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: protobuf-deserialize-action
properties:
schema: "message Person { required string first = 1; required string last = 2; }"
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
45.3.1.1. 前提条件
接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
45.3.1.2. クラスター CLI の使用手順
-
protobuf-deserialize-action-binding.yamlファイルをローカルドライブに保存し、必要に応じて編集します。 以下のコマンドを使用して、アクションを実行します。
oc apply -f protobuf-deserialize-action-binding.yaml
45.3.1.3. Kamel CLI を使用するための手順
以下のコマンドを使用して、アクションを設定および実行します。
kamel bind --name protobuf-deserialize-action-binding timer-source?message='{"first":"John","last":"Doe"}' --step json-deserialize-action --step protobuf-serialize-action -p step-1.schema='message Person { required string first = 1; required string last = 2; }' --step protobuf-deserialize-action -p step-2.schema='message Person { required string first = 1; required string last = 2; }' channel:mychannelこのコマンドは、クラスターの現在の namespace に KameletBinding を作成します。