在 AWS Kinesis Client Library (KCL)中有一个示例生成器,其中包含以下代码:
for (int j = 0; j < 10; ++j)
{
PutRecordRequest requestRecord = new PutRecordRequest();
requestRecord.StreamName = myStreamName;
requestRecord.Data = new MemoryStream(Encoding.UTF8.GetBytes("testData-" + j));
requestRecord.PartitionKey = "partitionKey-" + j;
PutRecordResult putResult = kinesisClient.PutRecord(requestRecord);
Console.Error.WriteLine(
String.Format("Successfully putrecord {0}:\n\t partition key = {1,15}, shard ID = {2}",
j, requestRecord.PartitionKey, putResult.ShardId));
}
为什么 MemoryStream 会这样?他们不应该处理流吗?谢谢