英文:
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();
答案1
得分: 1
如果您想阅读最早可用的消息,您需要将碎片迭代器类型设置为TRIM_HORIZON
,这将从碎片中最早可用的记录开始。
如果您还知道要从哪个序列号开始,您可以将其设置为AT_SEQUENCE_NUMBER
或AFTER_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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论