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.55.3. 使用方法
ここでは、protobuf-deserialize-action
の使用方法について説明します。
55.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
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
55.3.1.1. 前提条件
接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
55.3.1.2. クラスター CLI の使用手順
-
protobuf-deserialize-action-binding.yaml
ファイルをローカルドライブに保存し、必要に応じて編集します。 以下のコマンドを使用して、アクションを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f protobuf-deserialize-action-binding.yaml
oc apply -f protobuf-deserialize-action-binding.yaml
55.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
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 を作成します。