35.3. 使用方法
本セクションでは、topic-name-matches-filter-action を使用する方法を説明します。
35.3.1. Kafka Action
topic-name-matches-filter-action Kamelet を Kafka バインディングの中間ステップとして使用することができます。
topic-name-matches-filter-action-binding.yaml
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: topic-name-matches-filter-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: topic-name-matches-filter-action
properties:
regex: "The Regex"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
35.3.1.1. 前提条件
AMQ Streams Operator を OpenShift クラスターにインストールし、現在の namespace に my-topic という名前のトピックを作成していることを確認します。接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
35.3.1.2. クラスター CLI の使用手順
-
topic-name-matches-filter-action-binding.yamlファイルをローカルドライブに保存し、設定に合わせて編集します。 以下のコマンドを使用して、アクションを実行します。
oc apply -f topic-name-matches-filter-action-binding.yaml
35.3.1.3. Kamel CLI を使用するための手順
以下のコマンドを使用して、アクションを設定および実行します。
kamel bind timer-source?message=Hello --step topic-name-matches-filter-action -p "step-0.regex=The Regex" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。