简体   繁体   English

aws kinesis 迭代器过期时如何刷新它?

[英]How can I refresh the aws kinesis iterator when it get expired?

In my spring boot(1.5.7) application I was using the camel kinesis component for reading data from kinesis stream.在我的 spring boot(1.5.7) 应用程序中,我使用骆驼运动组件从运动流中读取数据。 I have set the Iterator type as "LATEST" as show below我已将迭代器类型设置为“最新”,如下所示

@Override
public void configure() throws Exception {
    from("aws-kinesis://"+stream+"?amazonKinesisClient=#awsClient&iteratorType="LATEST")
            .bean(Settlement.class, "transform")
            .to("log:out");

}

While reading continuously from the kinesis stream there were no issues.从 kinesis 流中连续读取时,没有任何问题。 But when there were some delay in processing the messages due to errors while processing and if that delay interval is beyond 5 minutes, I was getting an ExpiredIteratorException error as shown below但是当由于处理过程中的错误而在处理消息时出现一些延迟并且如果延迟间隔超过 5 分钟,我会收到一个 ExpiredIteratorException 错误,如下所示

om.amazonaws.services.kinesis.model.ExpiredIteratorException: Iterator expired. The iterator was created at time Mon Nov 27 15:30:29 UTC 2017 while right now it is Mon Nov 27 15:36:13 UTC 2017 which is further in the future than the tolerated delay of 300000 milliseconds. (Service: AmazonKinesis; Status Code: 400; Error Code: ExpiredIteratorException; Request ID: c655b6d8-58f4-c087-94c3-85f5e7cfdd03)

I have tried using it in camel versions 2.20.1 and 2.20.0.我曾尝试在骆驼版本 2.20.1 和 2.20.0 中使用它。 Is there any way to refresh the iterator?有没有办法刷新迭代器? or any other better solutions to overcome this problems in such a way I can read the next message available in the stream.或任何其他更好的解决方案来克服这个问题,我可以读取流中可用的下一条消息。

You can use subscribe_to_shard providing ConsumerARN , ShardId , position , sequence number as parameters for again reconnecting to shard as iterator expires in 300000 milliseconds.您可以使用subscribe_to_shard提供ConsumerARNShardIdpositionsequence number作为参数,以便在迭代器在300000毫秒后到期时再次重新连接到分片。

[aws doc] : https://docs.aws.amazon.com/kinesis/latest/APIReference/API_SubscribeToShard.html [aws 文档]: https : //docs.aws.amazon.com/kinesis/latest/APIReference/API_SubscribeToShard.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM