Spring Cloud 应用程序无法连接到 AWS Kinesis 'dynamoDBClient'且不得为空



由于错误java.lang.IllegalArgumentException: 'dynamoDBClient'必须不为null,无法使用Spring Cloud stream连接Kinesis流

//流绑定
EnableBinding(DataStream.class)
public class StreamsConfig {}

//流配置

public interface DataStream {

String AUDIT_IN = "auditIn";
@Input(AUDIT_IN)
SubscribableChannel auditIn();
}

//流侦听器
@StreamListener(DataStream.AUDIT_IN)
public void processAudit(finalAuditMessage auditMessage) {
logger.info("Received audit message : {}", auditMessage);
MDCUtil.setContext(auditMessage.getTenantId(), null, null);
persistAuditMessage(auditMessage);
MDCUtil.clearContext();
}

Application.yaml

cloud:
aws:
stack:
auto: false
region:
static: us-west-2
credentials:
useDefaultAwsCredentialsChain: true
management:
context-path: /actuator
security:
enabled: false
roles: ADMIN
endpoint:
metrics:
enabled: true
loggers:
enabled: true
health:
show-details: always
endpoints:
web:
exposure:
include: "health,metrics,info,loggers"
metrics:
export:
statsd:
enabled: true
flavor: telegraf
host: telegraf-s.cluster-services.svc.cluster.local
port: 8125
tags:
service: audit
namespace: {{ .Release.Namespace }}
distribution:
percentiles:
http:
server:
requests: 0.5,0.9,0.99
percentiles-histogram:
http:
server:
requests: true
logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE

spring:
application:
name: audit
zipkin:
enabled: false
cloud:
stream:
bindings:
auditIn:
content-type: application/json
destination: ***
consumer:
describeStreamRetries: 10
group: ***
kinesis:
binder:
autoCreateStream: true
autoAddShards: false
kplKclEnabled: true
vault:
token: 00000000-0000-0000-0000-000000000000
ssl:
trust-store: ***
trust-store-password: ***
generic:
enabled: false
host: localhost
port: 8200
scheme: https
connection:
timeout: 5000
read-timeout: 15000
authentication: KUBERNETES
kubernetes:
role: owner
kubernetes-path: kubernetes
service-account-token-file: token
kv:
enabled: false
backend: kv-v2
application-name: configuration/mysql
jpa:
open-in-view: false
audit:
filter:
block:
methods: GET

调试日志

INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: osx-x86_64
[INFO]
[INFO] ---------------------------< com.nile:audit >---------------------------
[INFO] Building audit 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) > test-compile @ audit >>>
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ audit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ audit ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ audit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ audit ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) < test-compile @ audit <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) @ audit ---
[INFO] Attaching agents: []
.   ____          _            __ _ _
/\ / ___'_ __ _ _(_)_ __  __ _    
( ( )___ | '_ | '_| | '_ / _` |    
\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.2.2.RELEASE)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/Users/arvindkgs/.m2/repository/org/springframework/spring-core/5.2.2.RELEASE/spring-core-5.2.2.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-02-24 20:40:38,529 ERROR [main] com.nile.cloudutilities.audit.aspect.MethodMap                [] [] - STARTING AUDIT BUILD AT 2021-02-24T15:10:38.524052Z
2021-02-24 20:40:39,984 ERROR [main] com.nile.cloudutilities.audit.aspect.MethodMap                [] [] - FINISHED AUDIT BUILD AT 2021-02-24T15:10:39.984543Z: 3/14/0 (0 mappings)
Running custom WebSecurity
2021-02-24 20:40:52,203 DEBUG [main] org.hibernate.SQL                                             [] [] - select loggerconf0_.id as id1_2_, loggerconf0_.create_time as create_t2_2_, loggerconf0_.last_update as last_upd3_2_, loggerconf0_.configuration as configur4_2_, loggerconf0_.service as service5_2_ from logger_configs loggerconf0_ where loggerconf0_.service=?
2021-02-24 20:40:52,219 TRACE [main] org.hibernate.type.descriptor.sql.BasicBinder                 [] [] - binding parameter [1] as [VARCHAR] - [audit]
2021-02-24 20:40:54,068 ERROR [main] org.springframework.cloud.stream.binding.BindingService       [] [] - Failed to create consumer binding; retrying in 30 seconds
org.springframework.cloud.stream.binder.BinderException: Exception thrown while starting consumer:
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:471) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:90) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:143) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.BindingService.doBindConsumer(BindingService.java:169) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.BindingService.bindConsumer(BindingService.java:126) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.AbstractBindableProxyFactory.createAndBindInputs(AbstractBindableProxyFactory.java:112) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.InputBindingLifecycle.doStartWithBindable(InputBindingLifecycle.java:58) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.AbstractBindingLifecycle$$Lambda$1628/000000000000000000.accept(Unknown Source) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608) [?:?]
at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.start(AbstractBindingLifecycle.java:57) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.cloud.stream.binding.InputBindingLifecycle.start(InputBindingLifecycle.java:34) [spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at com.nile.audit.AuditService.main(AuditService.java:60) [classes/:?]
Caused by: java.lang.IllegalArgumentException: 'dynamoDBClient' must not be null.
at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.integration.aws.inbound.kinesis.KclMessageDrivenChannelAdapter.<init>(KclMessageDrivenChannelAdapter.java:143) ~[spring-integration-aws-2.3.0.RELEASE.jar:?]
at org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.createKclConsumerEndpoint(KinesisMessageChannelBinder.java:314) ~[spring-cloud-stream-binder-kinesis-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.createConsumerEndpoint(KinesisMessageChannelBinder.java:291) ~[spring-cloud-stream-binder-kinesis-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.stream.binder.kinesis.KinesisMessageChannelBinder.createConsumerEndpoint(KinesisMessageChannelBinder.java:89) ~[spring-cloud-stream-binder-kinesis-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:417) ~[spring-cloud-stream-3.0.1.RELEASE.jar:3.0.1.RELEASE]
... 23 more
2021-02-24 20:40:54,167 DEBUG [main] org.hibernate.SQL                                             [] [] - select loggerconf0_.id as id1_2_, loggerconf0_.create_time as create_t2_2_, loggerconf0_.last_update as last_upd3_2_, loggerconf0_.configuration as configur4_2_, loggerconf0_.service as service5_2_ from logger_configs loggerconf0_ where loggerconf0_.service=?
2021-02-24 20:40:54,169 TRACE [main] org.hibernate.type.descriptor.sql.BasicBinder                 [] [] - binding parameter [1] as [VARCHAR] - [audit]
^C[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  49.955 s
[INFO] Finished at: 2021-02-24T20:40:58+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.

pom.xml - https://drive.google.com/file/d/1kBEj6HqTQS5BgA7StaFZBEKfbLrpgSMR/view?usp=sharing

使用以下jar

org.springframework.cloud:spring-cloud-stream-binder-kinesis:jar:2.0.0.RELEASE:compile
[INFO] |  +- com.amazonaws:amazon-kinesis-client:jar:1.13.0:compile
[INFO] |  |  +- com.amazonaws:aws-java-sdk-cloudwatch:jar:1.11.655:compile
[INFO] |  |  - com.google.protobuf:protobuf-java:jar:2.6.1:compile
[INFO] |  +- com.amazonaws:amazon-kinesis-producer:jar:0.14.0:compile
[INFO] |  |  - commons-lang:commons-lang:jar:2.6:compile
[INFO] |  +- org.springframework.integration:spring-integration-aws:jar:2.3.0.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-aws-core:jar:2.2.0.RELEASE:compile
[INFO] |  |  |  +- com.amazonaws:aws-java-sdk-ec2:jar:1.11.415:compile
[INFO] |  |  |  - com.amazonaws:aws-java-sdk-cloudformation:jar:1.11.415:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-aws-messaging:jar:2.2.0.RELEASE:runtime
[INFO] |  |  |  +- com.amazonaws:aws-java-sdk-sns:jar:1.11.415:runtime
[INFO] |  |  |  - com.amazonaws:aws-java-sdk-sqs:jar:1.11.415:runtime
[INFO] |  |  +- org.springframework.integration:spring-integration-file:jar:5.2.2.RELEASE:runtime
[INFO] |  |  - org.springframework.integration:spring-integration-http:jar:5.2.2.RELEASE:runtime
[INFO] |  +- org.springframework.cloud:spring-cloud-starter-aws:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-aws-context:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-aws-autoconfigure:jar:2.2.0.RELEASE:compile
[INFO] |  |  - javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.11.415:compile
[INFO] |  |  - com.amazonaws:aws-java-sdk-s3:jar:1.11.415:compile
[INFO] |  |     - com.amazonaws:aws-java-sdk-kms:jar:1.11.415:compile
[INFO] |  +- com.amazonaws:dynamodb-lock-client:jar:1.1.0:compile
[INFO] |  |  - org.apache.httpcomponents:httpcore:jar:4.4.12:compile
[INFO] |  +- com.amazonaws:aws-java-sdk-kinesis:jar:1.11.415:compile
[INFO] |  - com.amazonaws:dynamodb-streams-kinesis-adapter:jar:1.5.0:compile

要使用Spring BOOT应用程序和AWS API,请尝试使用Java V2 API的官方AWS SDK(而不是非Amazon API)。Amazon推荐从V1升级到V2

下面是一个在Spring BOOT应用程序中使用DynamoDB API V2的示例。这个用例允许用户从简单的web表单提交数据,然后将数据存储在Amazon DynamoDB表中。然后向您展示如何使用SNS发送短信。此外,这还向您展示了如何在Spring Boot应用程序中成功使用AWS Java V2 api。

写好之后,下面的代码将向您展示如何将Spring Boot应用程序部署到云上:

创建第一个AWS Java web应用程序

一旦你获得了使用AWS Java V2 api的基本Spring应用程序,你就可以使用其他服务了。

我的错。我正在创建一个返回null的DynamoDBClient bean。这个bean在org.springframework.云。stream.binder.kinesis. kinesismessagechannelbinder中自动连接。

相关内容

  • 没有找到相关文章

最新更新