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.3.3.2. Kafka Action
您可以使用 avro-serialize-action
Kamelet 作为 Kafka 绑定中的中间步骤。
avro-serialize-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: avro-serialize-action-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: timer-source properties: message: '{"first":"Ada","last":"Lovelace"}' steps: - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: json-deserialize-action - ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: avro-serialize-action properties: schema: "{\"type\": \"record\", \"namespace\": \"com.example\", \"name\": \"FullName\", \"fields\": [{\"name\": \"first\", \"type\": \"string\"},{\"name\": \"last\", \"type\": \"string\"}]}" sink: ref: kind: KafkaTopic apiVersion: kafka.strimzi.io/v1beta1 name: my-topic
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: avro-serialize-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: '{"first":"Ada","last":"Lovelace"}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: json-deserialize-action
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: avro-serialize-action
properties:
schema: "{\"type\": \"record\", \"namespace\": \"com.example\", \"name\": \"FullName\", \"fields\": [{\"name\": \"first\", \"type\": \"string\"},{\"name\": \"last\", \"type\": \"string\"}]}"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
Copy to clipboardCopied3.3.2.1. 先决条件
确保已在 OpenShift 集群中安装了 AMQ Streams Operator,并在当前命名空间中创建一个名为 my-topic
的主题。确保已将 "Red Hat Integration - Camel K" 安装到您连接到的 OpenShift 集群中。