首页 > 解决方案 > Failed to start bean 'inputBindingLifecycle' - A consumer group is required for a partitioned subscription

问题描述

I'm having a problem on test a Spring Cloud Stream 3.1.3 application. I've this application.yml:

...
spring:
  cloud:
    stream:
      bindings:
        input-in-0:
          destination: {DESTINATION}
          contentType: application/json
          group: {GROUP}
...

Obviously I wrote a Consumer method annotated with @Bean that I named input();

I replaced, for tests, this dependency

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-stream-test-support</artifactId>
  <scope>test</scope>
</dependency>

with this

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-stream</artifactId>
    <type>test-jar</type>
    <scope>test</scope>
    <classifier>test-binder</classifier>
</dependency>

And finally this is the test class:

@SpringBootTest
class ApplicationTest {
    @Autowired
    private Application application;

    @Test
    void shouldStartTheApplication(){
        Assertions.assertNotNull(application);
    }
}

Now, when I run this test with new test-binder dependency, test fails and logs this exception:

Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'; nested exception is java.lang.IllegalArgumentException: A consumer group is required for a partitioned subscription

Instead, if I don't replace spring-cloud-stream-test-support, test passes.

Why, according dependencies I use, is test result different? Thank you

标签: spring-bootspring-cloudspring-cloud-stream

解决方案


推荐阅读