ストリームからのメッセージの消費
ストリーミング・サービスのストリームからメッセージを消費します。
メッセージの消費に関する要件を確認するには、メッセージの消費を参照してください。
コンソールを使用してメッセージを消費することはできませんが、コンソールを使用してストリーム内の最近のメッセージを表示できます。
- コンソールのストリーミング・サービスにアクセスします。
- ストリーム・ページで、最近のメッセージを表示するストリームの名前をクリックします。
- ストリームの詳細ページの「最近のメッセージ」で、「メッセージのロード」をクリックします。
CLIの使用の詳細は、コマンド・ライン・インタフェース(CLI)を参照してください。CLIコマンドで使用できるフラグおよびオプションの完全なリストは、コマンドライン・リファレンスを参照してください。
カーソルを作成するにはoci streaming stream cursor create-cursor --stream-id <stream_OCID> --partition <partition> --type <cursor_type> --endpoint <messages_endpoint>
例:
oci streaming stream cursor create-cursor --stream-id ocid1.stream.oc1.phx.exampleuniqueID --partition 0 --type TRIM_HORIZON --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com { "data": { "value": "examplecursorvalue" } }
グループ・カーソルを作成するにはoci streaming stream cursor create-group-cursor --stream-id <stream_OCID> --group-name <consumer_group_name> --type <cursor_type> --endpoint <messages_endpoint>
例:
oci streaming stream cursor create-group-cursor --stream-id ocid1.stream.oc1.phx.exampleuniqueID --group-name MyConsumerGroup --type TRIM_HORIZON --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com { "data": { "value": "examplegroupcursorvalue" } }
メッセージを取得するにはoci streaming stream message get --stream-id <stream_OCID> --cursor <cursor> --endpoint <messages_endpoint>
メッセージを取得する最初のリクエストでは、カーソルの作成時に返された値を使用する必要があります。後続の各リクエストでは、前のレスポンスで返された
opc-next-cursor
値を使用する必要があります。例:
oci streaming stream message get --stream-id ocid1.stream.oc1.phx.exampleuniqueID --cursor examplecursorvalue --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com { "data": [ { "key": "a2V5MQ==", "offset": 0, "partition": "0", "stream": "MyStream", "timestamp": "2020-11-03T21:52:58.470000+00:00", "value": "dmFsdWUx" }, { "key": "a2V5Mg==", "offset": 1, "partition": "0", "stream": "MyStream", "timestamp": "2020-11-03T21:52:58.470000+00:00", "value": "dmFsdWUy" }, { "key": "a2V5MQ==", "offset": 2, "partition": "0", "stream": "MyStream", "timestamp": "2020-11-03T22:00:48.305000+00:00", "value": "dmFsdWUx" }, { "key": "a2V5Mg==", "offset": 3, "partition": "0", "stream": "MyStream", "timestamp": "2020-11-03T22:00:48.305000+00:00", "value": "dmFsdWUy" } ], "opc-next-cursor": "examplenextcursorvalue" }
ハートビートを送信するにはoci streaming stream group heartbeat --stream-id <stream_OCID> --cursor <cursor> --endpoint <messages_endpoint>
最初のハートビート・リクエストでは、グループ・カーソルの作成時に返された値を使用する必要があります。後続の各リクエストでは、前のレスポンスで返された
value
を使用する必要があります。例:
oci streaming stream group heartbeat --stream-id ocid1.stream.oc1.phx.exampleuniqueID --cursor examplecursorvalue --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com { "data": { "value": "examplenextcursorvalue" } }
APIの使用およびリクエストの署名の詳細は、REST APIのドキュメントおよびセキュリティ資格証明を参照してください。SDKの詳細は、SDKおよびCLIを参照してください。
次のAPI操作を使用して、メッセージを消費します: