首页 > 解决方案 > 带有 kinesis 的 Spring 云流:AmazonDynamoDBLockClient 在循环中抛出异常

问题描述

我们有一个非常简单的 spring-cloud-stream 应用程序,它从 AWS-Kinesis 队列中读取数据。它已经工作了一段时间没有问题。它只有很小的工作量。

今天,我们每秒收到 100 多个异常。(这比我们在这个应用程序上拥有的用户还多,所以它看起来像是一个无休止的重试循环)

WARN --- [s-shard-locks-1] c.a.s.d.AmazonDynamoDBLockClient : 
    Could not acquire lock because of a client side failure in talking to DDB
com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputExceededException: 
    The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ProvisionedThroughputExceededException
...
at org.springframework.integration.aws.lock.DynamoDbLockRegistry$DynamoDbLock.doLock(DynamoDbLockRegistry.java:504) 

代码很简单:

    @StreamListener(Channels.OUR_CHANNEL)
fun consumeThing(Thing: MutableMap<Any, Any>) {
    log.info("thing received: {}.", thing)
    // some methods to write it to our own datbase
}

我们只有一个基本配置:

spring:
  cloud:
    stream:
      defaultBinder: kinesis
      bindings:
        thingsChannel:
          group: aGroup
          destination: aDestionation

在 AWS-Console 中,我们看到一条警告,指出在 DynamoBD 中 SpringIntegrationLockRegistry 超出了读取容量。我们把它从1到10,但仍然有问题。

如何配置 spring-data-cloud 和 kinesis 使其更具弹性,并且在没有等待时间的情况下不要重试?

标签: spring-cloud-streamamazon-kinesis

解决方案


请查看以下可能的选项LockRegistryhttps ://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/blob/master/spring-cloud-stream-binder-kinesis-docs/ src/main/asciidoc/overview.adoc#lockregistry

看起来 AWS 控制台中表上的策略已更改。您可能需要重新考虑该表或我提到的客户端的一些超时和读写容量。

您可以在此处阅读有关 DynamoDB Lock Client 的更多信息,它已经不受 Spring Cloud Stream 控制。顺便说一句,这是项目的名称,而不是data...


推荐阅读