当前位置: 首页 > 知识库问答 >
问题:

在本地运行的最新Spring Cloud升级后,Spring Cloud Kinesis启动失败

包唯
2023-03-14

在将我们的Spring云微服务(打包为Docker镜像)部署到AWS之前,我们在本地针对LocalStack进行测试。因此,我们在自动配置的代码库中定义了如下bean:

  @Bean("amazonKinesisAsyncMyBean")
  @Primary
  @Conditional(value = {LocalStackProfileCondition.class})
  public AmazonKinesisAsync localAmazonKinesisAsync(
      final LocalStackProfileProperties localStackProfileProperties,
      final LocalStackProperties localStackProperties,
      AWSCredentialsProvider awsCredentialsProvider) {
    System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
    System.setProperty(SDKGlobalConfiguration.DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "true");
    return AmazonKinesisAsyncClientBuilder.standard()
        .withEndpointConfiguration(
            new AwsClientBuilder.EndpointConfiguration(
                generateUriString(
                    localStackProperties.getProtocol().toLowerCase(),
                    localStackProperties.getHost(),
                    localStackProperties.getKinesis().getPort()),
                localStackProfileProperties.getClient().getRegion()))
        .withCredentials(awsCredentialsProvider)
        .build();
  }

使用Spring Boot 2.3.5。RELEASE、Spring Cloud Hoxton。SR4和Spring Cloud Stream Binder Kinesis 2.0.1。RELEASE,我们能够针对LocalStack在本地成功测试我们的Docker容器。但是,升级到Spring Cloud Hoxton后。SR9我们在以下堆栈跟踪方面失败了:

Caused by: com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to squid.acme.com:8080 [squid.acme.com/x.x.x.x, squid.acme.com/x.x.x.x, squid.acme.com/x.x.x.x] failed: connect timed out
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1207)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1153)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.doInvoke(AmazonKinesisClient.java:2809)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:2776)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:2765)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.executeDescribeStream(AmazonKinesisClient.java:875)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.describeStream(AmazonKinesisClient.java:846)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.createOrUpdate(KinesisStreamProvisioner.java:135)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.provisionProducerDestination(KinesisStreamProvisioner.java:91)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.provisionProducerDestination(KinesisStreamProvisioner.java:57)
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:223)
    ... 33 common frames omitted

我们的本地开发环境与互联网隔离,因此通过代理的连接超时。无论如何,首先的问题是,在升级Spring Cloud之后,Kinesis binder似乎正在尝试连接到AWS以获取碎片列表。在使用新配置运行时,如何确保这些请求路由到LocalStack而不是AWS?

更新1:

将Spring Cloud Stream Kinesis Binder更新为2.0.3后。RELEASE,下面是我现在收到的堆栈跟踪:

Caused by: com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to squid.acme.com:8080 [squid.acme.com/x.x.x.x, squid.acme.com/x.x.x.x, squid.acme.com/x.x.x.x] failed: connect timed out
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1207)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1153)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.doInvoke(AmazonKinesisClient.java:2809)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:2776)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:2765)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.executeListShards(AmazonKinesisClient.java:1557)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.listShards(AmazonKinesisClient.java:1528)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.getShardList(KinesisStreamProvisioner.java:141)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.getShardList(KinesisStreamProvisioner.java:122)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.createOrUpdate(KinesisStreamProvisioner.java:167)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.provisionProducerDestination(KinesisStreamProvisioner.java:93)
    at org.springframework.cloud.stream.binder.kinesis.provisioning.KinesisStreamProvisioner.provisionProducerDestination(KinesisStreamProvisioner.java:59)
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindProducer(AbstractMessageChannelBinder.java:223)
    ... 33 common frames omitted

更新2:

org.springframework日志记录级别设置为DEBUG后,我能够捕获以下条件评估报告:

============================
CONDITIONS EVALUATION REPORT
============================


Positive matches:
-----------------

   ContextCredentialsAutoConfiguration matched:
      - @ConditionalOnClass found required class 'com.amazonaws.auth.AWSCredentialsProvider' (OnClassCondition)

   KinesisBinderConfiguration matched:
      - @ConditionalOnMissingBean (types: org.springframework.cloud.stream.binder.Binder; SearchStrategy: all) did not find any beans (OnBeanCondition)

   KinesisBinderConfiguration#dynamoDBStreams matched:
      - @ConditionalOnMissingBean (types: com.amazonaws.services.dynamodbv2.AmazonDynamoDBStreams; SearchStrategy: all) did not find any beans (OnBeanCondition)

   KinesisBinderConfiguration.KinesisBinderHealthIndicatorConfiguration matched:
      - @ConditionalOnClass found required class 'org.springframework.boot.actuate.health.HealthIndicator' (OnClassCondition)
      - @ConditionalOnEnabledHealthIndicator management.health.defaults.enabled is considered true (OnEnabledHealthIndicatorCondition)

   KinesisBinderConfiguration.KinesisBinderHealthIndicatorConfiguration#kinesisBinderHealthIndicator matched:
      - @ConditionalOnMissingBean (names: kinesisBinderHealthIndicator; SearchStrategy: all) did not find any beans (OnBeanCondition)


Negative matches:
-----------------

   KinesisBinderConfiguration#amazonKinesis:
      Did not match:
         - @ConditionalOnMissingBean (types: com.amazonaws.services.kinesis.AmazonKinesisAsync; SearchStrategy: all) found beans of type 'com.amazonaws.services.kinesis.AmazonKinesisAsync' amazonKinesisAsyncMyBean (OnBeanCondition)

   KinesisBinderConfiguration#cloudWatch:
      Did not match:
         - @ConditionalOnMissingBean (types: com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync; SearchStrategy: all) found beans of type 'com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync' amazonCloudWatchAsync (OnBeanCondition)
      Matched:
         - @ConditionalOnProperty (spring.cloud.stream.kinesis.binder.kpl-kcl-enabled) matched (OnPropertyCondition)

   KinesisBinderConfiguration#dynamoDB:
      Did not match:
         - @ConditionalOnMissingBean (types: com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync; SearchStrategy: all) found beans of type 'com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync' amazonDynamoDBAsync (OnBeanCondition)

   KinesisBinderConfiguration#dynamoDBLockRegistry:
      Did not match:
         - @ConditionalOnProperty (spring.cloud.stream.kinesis.binder.kpl-kcl-enabled=false) found different value in property 'spring.cloud.stream.kinesis.binder.kpl-kcl-enabled' (OnPropertyCondition)

   KinesisBinderConfiguration#kinesisCheckpointStore:
      Did not match:
         - @ConditionalOnProperty (spring.cloud.stream.kinesis.binder.kpl-kcl-enabled=false) found different value in property 'spring.cloud.stream.kinesis.binder.kpl-kcl-enabled' (OnPropertyCondition)

   KinesisBinderConfiguration#kinesisProducerConfiguration:
      Did not match:
         - @ConditionalOnMissingBean (types: com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration; SearchStrategy: all) found beans of type 'com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration' kinesisProducerConfiguration (OnBeanCondition)
      Matched:
         - @ConditionalOnProperty (spring.cloud.stream.kinesis.binder.kpl-kcl-enabled) matched (OnPropertyCondition)


Exclusions:
-----------

    None


Unconditional classes:
----------------------

    None

共有1个答案

徐德海
2023-03-14

让我们再看一次这种情况:

 KinesisBinderConfiguration#amazonKinesis:
      Did not match:
         - @ConditionalOnMissingBean (types: com.amazonaws.services.kinesis.AmazonKinesisAsync; SearchStrategy: all) found beans of type 'com.amazonaws.services.kinesis.AmazonKinesisAsync' amazonKinesisAsync (OnBeanCondition)

注意amazonKinesis Asyncbean名称。它看起来不属于您配置中提到的localAmazon Kinesis Asyncbean。可能您的条件以某种方式不起作用,另一个Amazon Kinesis Asyncbean获胜,它已经指向squid.acme.com:8080endpoint...

 类似资料:
  • 我将camel从2.8.0升级到2.10.3版本,我的sftp组件开始出现故障。Afaik,sftp组件默认使用stepwise,在升级之前没有更改目录的麻烦。 cd与V2.8.0兼容 20130114 18:42:52,956信息[Camel(camel-1)线程#0-sftp://user@host/outgoing]remoteFileConsumer[133]:连接并登录到:sftp://

  • 我已经升级到MacOS Sierra,我的Netbeans 8.0.2在尝试运行Glassfish时抛出一个错误。 请检查服务器管理员用户名和密码属性。 另外,请检查服务器日志文件以了解其他可能的原因。 我尝试了在stackoverflow中找到的所有可行的解决方案,但都没有成功。 Glassfish 4 Admin未从Netbeans 7.4运行(密码不正确) 这是玻璃鱼的日志 我不知道还能做什

  • 我已经升级了build.sbt以使用最新的play-slick(2.0.0),但在下载并将应用程序设置为运行后,我遇到了这个异常。 `java.lang.nosuchmethoderror:play.api.logger$.init(ljava/io/file;lscala/enumeration$value;)V at play.core.server.devserverstart$$anonf

  • Flask 如同其它软件一样,会随着时间不停地更新自己,其中大部分都会是非常体贴的, 你无需改动一行自身代码就可以应用新版本的 Flask。 不过,每当 Flask 有更新时,我们都建议你适当地修改自己的代码,以充分地利用这些新功能, 提高自己代码地质量。 本章节文档为您列举了 Flask 各版本之间地差异,以及你如何修改自身代码才能无痛地升级。 如果你使用 easy_install 命令更新、安

  • 我在Ubuntu18.04上使用ELasticsearch。当我尝试运行“./elasticsearch-setup-passwords”脚本时,它显示以下错误。 未来版本的Elasticsearch将需要Java 11;您的Java版本[/usr/lib/jvm/java-8-openjdk-amd64/jre]不符合此要求 但当我检查Jaa版本时,它显示的是Java 11号。 我把Java从8

  • 我最近刚刚将团队的一个Spring Boot应用程序从2.1.3版升级到2.3.0版,并将Hibernate版本从5.3.6.final升级到5.4.15.final。 一切都很好,但是现在当应用程序在服务器上启动时,启动需要800-900秒(大约15分钟),而以前只需要30秒。 需要注意的是,当在localhost上运行2.1.3和2.3.0时,应用程序的启动是相同的,大约为12-15秒。 只有