Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubSubDeadLetterTopicSampleAppIntegrationTest failed with cast class exception #3139

Closed
ldetmer opened this issue Aug 19, 2024 · 2 comments
Closed
Assignees
Labels
priority: p1 type: bug Something isn't working

Comments

@ldetmer
Copy link
Contributor

ldetmer commented Aug 19, 2024

Error running PubSubDeadLetterTopicSampleAppIntegrationTest: testSample_deadLetterHandling

08:24:25.893 [global-gcp-pubsub-subscriber1] WARN  c.g.c.s.p.i.i.PubSubInboundChannelAdapter - error occurred in message handler [org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1@68347216]
08:24:29.895 [global-gcp-pubsub-subscriber3] ERROR o.s.i.handler.LoggingHandler - org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1@68347216], failedMessage=GenericMessage [payload=byte[127], headers=***id=47898e41-b4de-a94b-a74d-d86064f5ffe0, contentType=application/json, gcp_pubsub_original_message=PushedAcknowledgeablePubsubMessage***projectId='spring-cloud-gcp-ci', subscriptionName='anonymous.my-main-topic.32f1ddf2-791f-410f-bf55-dfd4ffd5b58b', message=data: "***\"body\":\"test message 5d63cca5-980e-4e83-ae2e-4eb14f459c65\",\"username\":\"testUserName\",\"createdAt\":[2024,8,19,8,24,6,337013596]***"
attributes ***
  key: "contentType"
  value: "application/json"
***
attributes ***
  key: "googclient_deliveryattempt"
  value: "3"
***
message_id: "11994779617011169"
publish_time ***
  seconds: 1724055846
  nanos: 468000000
***
***, googclient_deliveryattempt=3, timestamp=1724055869894***]
	at org.springframework.integration.support.utils.IntegrationUtils.wrapInHandlingExceptionIfNecessary(IntegrationUtils.java:191)
	at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:108)
	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
	at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:132)
	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148)
	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)
	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72)
	at org.springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:390)
	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:334)
	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:304)
	at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187)
	at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166)
	at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47)
	at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109)
	at org.springframework.integration.endpoint.MessageProducerSupport.lambda$sendMessage$1(MessageProducerSupport.java:262)
	at io.micrometer.observation.Observation.observe(Observation.java:499)
	at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:262)
	at com.google.cloud.spring.pubsub.integration.inbound.PubSubInboundChannelAdapter.consumeMessage(PubSubInboundChannelAdapter.java:146)
	at com.google.cloud.spring.pubsub.core.subscriber.PubSubSubscriberTemplate.lambda$subscribeAndConvert$1(PubSubSubscriberTemplate.java:172)
	at com.google.cloud.pubsub.v1.MessageDispatcher$3.run(MessageDispatcher.java:514)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassCastException: class [B cannot be cast to class com.example.UserMessage ([B is in module java.base of loader 'bootstrap'; com.example.UserMessage is in unnamed module of loader 'app')
	at com.example.SinkExample.lambda$logUserMessage$1(SinkExample.java:38)
	at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeConsumer(SimpleFunctionRegistry.java:1063)
	at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:761)
	at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:592)
	at org.springframework.cloud.stream.function.PartitionAwareFunctionWrapper.apply(PartitionAwareFunctionWrapper.java:92)
	at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionWrapper.apply(FunctionConfiguration.java:823)
	at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1.handleMessageInternal(FunctionConfiguration.java:654)
	at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:105)
	... 24 more

08:24:29.895 [global-gcp-pubsub-subscriber3] WARN  c.g.c.s.p.i.i.PubSubInboundChannelAdapter - Sending Spring message [11994779617011169] failed; message neither acked nor nacked.
08:24:29.896 [global-gcp-pubsub-subscriber3] WARN  c.g.c.s.p.i.i.PubSubInboundChannelAdapter - error occurred in message handler [org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1@68347216]
"
to contain:
  "Nacking message (attempt 1)"  within 1 minutes.
08:24:33:685 [INFO] 
Error: 3:685 [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
08:24:33:685 [INFO] 
08:24:33:685 [INFO] 
08:24:33:686 [INFO] --- failsafe:3.2.5:verify (default) @ spring-cloud-gcp-pubsub-stream-dead-letter-sample ---
08:24:33:688 [INFO] ------------------------------------------------------------------------
@ldetmer ldetmer added type: bug Something isn't working priority: p1 labels Aug 19, 2024
@ldetmer
Copy link
Contributor Author

ldetmer commented Aug 21, 2024

Note this is a known issue with spring-cloud-stream and a fix is already committed. The work around is posted here

ldetmer added a commit that referenced this issue Aug 22, 2024
…est #3139 (#3145)

* fix: Added object mapper bean to fix issue with spring cloud stream 4.1.3 failing to deserialize objects (spring-cloud/spring-cloud-stream#2977) causing pubsub steam dead letter and functional sample test to fail
@ldetmer
Copy link
Contributor Author

ldetmer commented Aug 23, 2024

Fixed in commit: ae3626a

@ldetmer ldetmer closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant