Which shard iterator type should I use, if I have to read messages from stream before application started running

huangapple go评论63阅读模式
英文:

Which shard iterator type should I use, if I have to read messages from stream before application started running

问题

以下是翻译好的内容:

如果在应用程序启动之前必须从流中读取消息,应该使用哪种分片迭代器类型?

我们的代码当前如下,但是分片迭代器类型“LATEST”不会读取在应用程序启动之前发布到流中的消息。我应该如何设置?

private String getShardIterator() {

       GetShardIteratorRequest itReq = GetShardIteratorRequest.builder()

               .streamName(streamName)

               .shardIteratorType("LATEST")

               .shardId("shardId-000000000000")

               .build();

参考:https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/kinesis/model/GetShardIteratorRequest.html

英文:

Which shard iterator type should I use if I have to read messages from the stream before the application started running

Our code looks like this right now, but shard iterator type LATEST doesn't read messages which were posted into the stream before the application started. How should I set this?

private String getShardIterator() {

       GetShardIteratorRequest itReq = GetShardIteratorRequest.builder()

               .streamName(streamName)

               .shardIteratorType("LATEST")

               .shardId("shardId-000000000000")

               .build();

Refer: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/kinesis/model/GetShardIteratorRequest.html

答案1

得分: 1

如果您想阅读最早可用的消息,您需要将碎片迭代器类型设置为TRIM_HORIZON,这将从碎片中最早可用的记录开始。

如果您还知道要从哪个序列号开始,您可以将其设置为AT_SEQUENCE_NUMBERAFTER_SEQUENCE_NUMBER,并额外提供起始序列号参数。

LATEST从您订阅后发布的最新记录开始。

英文:

If you want to read the most old messages available, you need to set the shard iterator type to TRIM_HORIZON, which will start from the oldest record available in the shard.

If you additionally know the seq num to start with, you can set it to AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER and additionally provide starting sequence number parameter.

The LATEST starts with the most recent record published after you subscribed.

huangapple
  • 本文由 发表于 2020年9月8日 15:02:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63788675.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定