question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception when using kafka and kafka-stream binders in the same app

See original GitHub issue

This looks like a benign exception but is annoying when running tests. Noticed when both spring-cloud-stream-binder-kafka and spring-cloud-stream-binder-kafka-stream are in the classpath. Here is the stack trace.

java.lang.ClassCastException: com.sun.proxy.$Proxy90 cannot be cast to org.springframework.messaging.MessageChannel
	at org.springframework.cloud.stream.test.binder.TestSupportBinder.bindConsumer(TestSupportBinder.java:67) ~[spring-cloud-stream-test-support-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindingService.doBindConsumer(BindingService.java:144) [spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindingService.bindConsumer(BindingService.java:112) [spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.cloud.stream.binding.BindableProxyFactory.createAndBindInputs(BindableProxyFactory.java:254) [spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.cloud.stream.binding.InputBindingLifecycle.doStartWithBindable(InputBindingLifecycle.java:58) [spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608) ~[na:1.8.0_161]
	at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.start(AbstractBindingLifecycle.java:48) ~[spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.cloud.stream.binding.InputBindingLifecycle.start(InputBindingLifecycle.java:34) [spring-cloud-stream-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sobychackocommented, Apr 9, 2020

@boonware @NandAtTSB Sorry for the delay in responding to this issue. Here are some details. The usage of spring-cloud-stream-test-support is discouraged in the 3.0.x versions of Spring Cloud Stream. The recommended artifact for testing message channel based binders is the new Spring Integration based test binder. With this new test binder, you no longer need the legacy spring-cloud-stream-test-support binder. Here is a sample, where I have both Kafka and Kafka Streams binders in the classpath that also includes this new test binder dependency. The provided test passes without throwing any exceptions in the log. Please note that in the sample, I don’t make use of the regular Kafka binder or the test binder. I just provided them to show how they can all co-exist in the same app without causing any issues.

If you must use the old test binder (spring-cloud-stream-test-binder), then you have to isolate the Kafka Streams specific tests to a test class and then exclude the TestSupportBinderAutoConfiguration. See these comments for more details.

Hope this helps. I am closing this issue. If you are still facing issues with this, please feel free to re-open this and add more details.

0reactions
venkatesh010commented, Jun 19, 2022

@sobychacko I tried this to run my spring cloud contract tests which requires spring cloud stream on classpath and normal message collector tests together

On basetest I have put

@ImportAutoConfiguration(TestChannelBinderConfiguration.class) @EnableAutoConfiguration(exclude = TestSupportBinderAutoConfiguration.class)

And Im getting exceptions, w.r.t Error creating bean messageCollector

Read more comments on GitHub >

github_iconTop Results From Across the Web

16. Apache Kafka Streams Binder - Spring
Kafka Streams binder supports a selection of exception handlers through the following properties. ... In addition to the above two deserialization exception ......
Read more >
Spring Cloud Kafka Stream Multibinder BeanCreationException
I am trying to create a spring boot application using spring cloud kafka stream which reads input from kafka cluster 1 and send...
Read more >
Configuring a Streams Application - Apache Kafka
The default production exception handler allows you to manage exceptions triggered when trying to interact with a broker such as attempting to produce...
Read more >
spring-cloud/spring-cloud-stream - Gitter
@elvisols I would like to see more of your code. Can you set up a small sample app? FWIW, you cannot mix both...
Read more >
Spring Cloud Stream Kafka (Part 3) - Functional Programming
Asynchronous communication between applications and using Apache Kafka as broker. ... <artifactId>spring-cloud-stream-binder-kafka-streams</artifactId> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found