Java 消费者无法处理消息-Spring Cloud Stream

Java 消费者无法处理消息-Spring Cloud Stream,java,json,spring,spring-cloud,amazon-kinesis,Java,Json,Spring,Spring Cloud,Amazon Kinesis,我有一个pub/sub模型,它使用SpringCloudStream-AmazonKinesis集成。我能够向消费者发布事件,但无法读取它们。我正在使用PutRecordsRequest批量发布消息。消费者正在接收列表,但无法读取和打印列表。我在日志中观察到以下错误 org.springframework.messaging.MessageHandlingException:在“MethodInvokingMessageProcessor”[org.springframework.integra

我有一个pub/sub模型,它使用SpringCloudStream-AmazonKinesis集成。我能够向消费者发布事件,但无法读取它们。我正在使用PutRecordsRequest批量发布消息。消费者正在接收列表,但无法读取和打印列表。我在日志中观察到以下错误

org.springframework.messaging.MessageHandlingException:在“MethodInvokingMessageProcessor”[org.springframework.integration.handler]中处理消息时出错。MethodInvokingMessageProcessor@1063cd77]; 嵌套异常为java.lang.ClassCastException:class com.amazonaws.services.kinesis.model.Record无法强制转换为class com.org.project.application.data.SomeEvent(com.amazonaws.services.kinesis.model.Record和com.org.project.application.data.SomeEvent位于加载器“app”的未命名模块中) 在org.springframework.integration.support.utils.IntegrationUtils.wrapinHandlingExceptionIfNeeded(IntegrationUtils.java:191)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:111)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.handler.ServiceActivationHandler.HandlerRequestMessage(ServiceActivationHandler.java:95)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:127)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:177)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.dispatcher.AbstractDispatcher.tryoOptimizedDispatch(AbstractDispatcher.java:115)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:133)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.dispatcher.UnicastingDispatcher.dispatcher(UnicastingDispatcher.java:106)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:73)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:453)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:403)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187)~[spring-messaging-5.2.12.RELEASE.jar:5.2.12.RELEASE] 在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166)~[spring-messaging-5.2.12.RELEASE.jar:5.2.12.RELEASE] 在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47)~[spring-messaging-5.2.12.RELEASE.jar:5.2.12.RELEASE] 在org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109)~[spring-messaging-5.2.12.RELEASE.jar:5.2.12.RELEASE] 在org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:198)~[spring-integration-core-5.2.11.RELEASE.jar:5.2.11.RELEASE] 在org.springframework.integration.aws.inbound.kinesis.kinesismsessagedrivenchanneladapter.access$4800(kinesismsessagedrivenchanneladapter.java:102)~[spring-integration-aws-2.3.5.RELEASE.jar:na] 在org.springframework.integration.aws.inbound.kinesis.kinesismsessagedrivenchanneladapter$ShardConsumer.performSend(kinesismsessagedrivenchanneladapter.java:1308)~[spring-integration-aws-2.3.5.RELEASE.jar:na] 在org.springframework.integration.aws.inbound.kinesis.kinesismsessagedrivenchanneladapter$ShardConsumer.processMultipleRecords(kinesismsessagedrivenchanneladapter.java:1254)~[spring-integration-aws-2.3.5.RELEASE.jar:na] 在org.springframework.integration.aws.inbound.kinesis.kinesismsessagedrivenchanneladapter$ShardConsumer.processRecords(kinesismsessagedrivenchanneladapter.java:1209)~[spring-integration-aws-2.3.5.RELEASE.jar:na] 在org.springframework.integration.aws.inbound.kinesis.kinesismsessagedrivenchanneladapter$ShardConsumer.lambda$processTask$1(kinesismsessagedrivenchanneladapter.java:1083)~[spring-integration-aws-2.3.5.RELEASE.jar:na] 在org.springframework.integration.aws.inbound.KinesisMessageDrivenChannelAdapter$ConsumerInvoker.run(KinesisMessageDrivenChannelAdapter.java:1401)~[spring-integration-aws-2.3.5.RELEASE.jar:na] 在java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)~[na:na] 在java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)~[na:na] 在java.base/java.lang.Thread.run(Thread.java:829)~[na:na]

@Bean
公共消费者someConsumerBatchProcessing(){
返回一些事件->{
logger.info(“已从Kinesis接收到SomeEvent”+someEvents.toString());
logEvent(“从Kinesis接收的某些事件”+someEvents.toString());
System.out.println(“消费者列表大小:+someEvents.Size());//接收到的大小非常好
System.out.println(“Consumer类中的某些对象”+someEvents.get(0.toString());//在此处接收java.lang.ClassCastException
System.out.println(“没有toString的使用者类中的某些对象”+someEvents.get(0));
consumerMethodThrowExceptionBatch();
};
}
 @Bean
public Consumer<List<SomeEvent>> someConsumerBatchProcessing(){
    return someEvents -> {
        logger.info("An SomeEvent has been received from Kinesis " + someEvents.toString());
        eventLogger.logEvent("Some event received from Kinesis" + someEvents.toString());
        System.out.println("Consumer List Size: "+someEvents.size()); //receiving the size perfectly fine
        System.out.println("Some Objects in Consumer Class"+someEvents.get(0).toString()); //receiving the java.lang.ClassCastException here
        System.out.println("Some Objects in Consumer Class Without toString"+someEvents.get(0));
        consumerMethodThrowExceptionBatch();
    };
}