文件範例儲存庫中有更多 AWS SDK可用的範例。 AWS SDK
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
RegisterStreamConsumer
搭配 AWS SDK或 使用 CLI
下列程式碼範例示範如何使用 RegisterStreamConsumer
。
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 using System; using System.Threading.Tasks; using Amazon.Kinesis; using Amazon.Kinesis.Model; /// <summary> /// This example shows how to register a consumer to an Amazon Kinesis /// stream. /// </summary> public class RegisterConsumer { public static async Task Main() { IAmazonKinesis client = new AmazonKinesisClient(); string consumerName = "NEW_CONSUMER_NAME"; string streamARN = "arn:aws:kinesis:us-east-2:000000000000:stream/AmazonKinesisStream"; var consumer = await RegisterConsumerAsync(client, consumerName, streamARN); if (consumer is not null) { Console.WriteLine($"{consumer.ConsumerName}"); } } /// <summary> /// Registers the consumer to a Kinesis stream. /// </summary> /// <param name="client">The initialized Kinesis client object.</param> /// <param name="consumerName">A string representing the consumer.</param> /// <param name="streamARN">The ARN of the stream.</param> /// <returns>A Consumer object that contains information about the consumer.</returns> public static async Task<Consumer> RegisterConsumerAsync(IAmazonKinesis client, string consumerName, string streamARN) { var request = new RegisterStreamConsumerRequest { ConsumerName = consumerName, StreamARN = streamARN, }; var response = await client.RegisterStreamConsumerAsync(request); return response.Consumer; } }
-
如需API詳細資訊,請參閱 參考 RegisterStreamConsumer中的 。 AWS SDK for .NET API
-
- CLI
-
- AWS CLI
-
註冊資料串流取用者
下列
register-stream-consumer
範例會註冊KinesisConsumerApplication
使用指定資料串流呼叫的取用者。aws kinesis register-stream-consumer \ --stream-arn
arn:aws:kinesis:us-west-2:012345678912:stream/samplestream
\ --consumer-nameKinesisConsumerApplication
輸出:
{ "Consumer": { "ConsumerName": "KinesisConsumerApplication", "ConsumerARN": "arn:aws:kinesis:us-west-2: 123456789012:stream/samplestream/consumer/KinesisConsumerApplication:1572383852", "ConsumerStatus": "CREATING", "ConsumerCreationTimestamp": 1572383852.0 } }
如需詳細資訊,請參閱 Amazon Kinesis Kinesis Data Streams 開發人員指南 中的使用 Kinesis Data Streams 開發具有增強型扇出的消費者API。
-
如需API詳細資訊,請參閱 命令參考 RegisterStreamConsumer
中的 。 AWS CLI
-
- SAP ABAP
-
- SDK 適用於 SAP ABAP
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. oo_result = lo_kns->registerstreamconsumer( " oo_result is returned for testing purposes. " iv_streamarn = iv_stream_arn iv_consumername = iv_consumer_name ). MESSAGE 'Stream consumer registered.' TYPE 'I'. CATCH /aws1/cx_knsinvalidargumentex . MESSAGE 'The specified argument was not valid.' TYPE 'E'. CATCH /aws1/cx_sgmresourcelimitexcd. MESSAGE 'You have reached the limit on the number of resources.' TYPE 'E'. CATCH /aws1/cx_sgmresourceinuse. MESSAGE 'Resource being accessed is in use.' TYPE 'E'. CATCH /aws1/cx_sgmresourcenotfound. MESSAGE 'Resource being accessed is not found.' TYPE 'E'. ENDTRY.
-
如需API詳細資訊,請參閱RegisterStreamConsumer中的 AWS SDK 以取得SAPABAPAPI參考 。
-
PutRecords
無伺服器範例