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.60.3. 使用方法
ここでは、salesforce-source
の使用方法について説明します。
60.3.1. Knative ソース
salesforce-source
Kamelet を Knative オブジェクトにバインドすることで、Knative ソースとして使用することができます。
salesforce-source-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: salesforce-source-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: salesforce-source properties: clientId: "The Consumer Key" clientSecret: "The Consumer Secret" password: "The Password" query: "SELECT Id, Name, Email, Phone FROM Contact" topicName: "ContactTopic" userName: "The Username" sink: ref: kind: Channel apiVersion: messaging.knative.dev/v1 name: mychannel
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: salesforce-source-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: salesforce-source
properties:
clientId: "The Consumer Key"
clientSecret: "The Consumer Secret"
password: "The Password"
query: "SELECT Id, Name, Email, Phone FROM Contact"
topicName: "ContactTopic"
userName: "The Username"
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
60.3.1.1. 前提条件
接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
60.3.1.2. クラスター CLI の使用手順
-
salesforce-source-binding.yaml
ファイルをローカルドライブに保存し、設定に合わせて編集します。 以下のコマンドを使用してソースを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f salesforce-source-binding.yaml
oc apply -f salesforce-source-binding.yaml
60.3.1.3. Kamel CLI を使用するための手順
以下のコマンドを使用してソースを設定および実行します。
kamel bind salesforce-source -p "source.clientId=The Consumer Key" -p "source.clientSecret=The Consumer Secret" -p "source.password=The Password" -p "source.query=SELECT Id, Name, Email, Phone FROM Contact" -p "source.topicName=ContactTopic" -p "source.userName=The Username" channel:mychannel
kamel bind salesforce-source -p "source.clientId=The Consumer Key" -p "source.clientSecret=The Consumer Secret" -p "source.password=The Password" -p "source.query=SELECT Id, Name, Email, Phone FROM Contact" -p "source.topicName=ContactTopic" -p "source.userName=The Username" channel:mychannel
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。
60.3.2. Kafka Source
salesforce-source
Kamelet を Kafka トピックにバインドすることにより、Kafka ソースとして使用できます。
salesforce-source-binding.yaml
apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: name: salesforce-source-binding spec: source: ref: kind: Kamelet apiVersion: camel.apache.org/v1alpha1 name: salesforce-source properties: clientId: "The Consumer Key" clientSecret: "The Consumer Secret" password: "The Password" query: "SELECT Id, Name, Email, Phone FROM Contact" topicName: "ContactTopic" userName: "The Username" sink: ref: kind: KafkaTopic apiVersion: kafka.strimzi.io/v1beta1 name: my-topic
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: salesforce-source-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: salesforce-source
properties:
clientId: "The Consumer Key"
clientSecret: "The Consumer Secret"
password: "The Password"
query: "SELECT Id, Name, Email, Phone FROM Contact"
topicName: "ContactTopic"
userName: "The Username"
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
60.3.2.1. 前提条件
AMQ Streams Operator を OpenShift クラスターにインストールし、現在の namespace に my-topic
という名前のトピックを作成していることを確認します。接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。
60.3.2.2. クラスター CLI の使用手順
-
salesforce-source-binding.yaml
ファイルをローカルドライブに保存し、設定に合わせて編集します。 以下のコマンドを使用してソースを実行します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc apply -f salesforce-source-binding.yaml
oc apply -f salesforce-source-binding.yaml
60.3.2.3. Kamel CLI を使用するための手順
以下のコマンドを使用してソースを設定および実行します。
kamel bind salesforce-source -p "source.clientId=The Consumer Key" -p "source.clientSecret=The Consumer Secret" -p "source.password=The Password" -p "source.query=SELECT Id, Name, Email, Phone FROM Contact" -p "source.topicName=ContactTopic" -p "source.userName=The Username" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
kamel bind salesforce-source -p "source.clientId=The Consumer Key" -p "source.clientSecret=The Consumer Secret" -p "source.password=The Password" -p "source.query=SELECT Id, Name, Email, Phone FROM Contact" -p "source.topicName=ContactTopic" -p "source.userName=The Username" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。