16.3. 使用方法

本セクションでは、cassandra-source を使用する方法を説明します。

16.3.1. Knative ソース

cassandra-source Kamelet を Knative オブジェクトにバインドすることで、Knative ソースとして使用することができます。

cassandra-source-binding.yaml

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: cassandra-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: cassandra-source
    properties:
      connectionHost: "localhost"
      connectionPort: 9042
      keyspace: "customers"
      password: "The Password"
      query: "The Query"
      username: "The Username"
  sink:
    ref:
      kind: Channel
      apiVersion: messaging.knative.dev/v1
      name: mychannel

16.3.1.1. 前提条件

接続先の OpenShift クラスターにRed Hat Integration - Camel Kがインストールされていることを確認します。

16.3.1.2. クラスター CLI の使用手順

  1. cassandra-source-binding.yaml ファイルをローカル・ドライブに保存し、必要に応じて設定を編集します。
  2. 以下のコマンドを使用してソースを実行します。

    oc apply -f cassandra-source-binding.yaml

16.3.1.3. Kamel CLI を使用するための手順

以下のコマンドを使用してソースを設定および実行します。

kamel bind cassandra-source -p "source.connectionHost=localhost" -p source.connectionPort=9042 -p "source.keyspace=customers" -p "source.password=The Password" -p "source.query=The Query" -p "source.username=The Username" channel:mychannel

このコマンドは、クラスターの現在の namespace に KameletBinding を作成します。