|
71 | 71 | import org.springframework.beans.factory.annotation.Autowired;
|
72 | 72 | import org.springframework.beans.factory.config.BeanDefinition;
|
73 | 73 | import org.springframework.beans.factory.config.BeanPostProcessor;
|
| 74 | +import org.springframework.beans.factory.config.ConfigurableBeanFactory; |
| 75 | +import org.springframework.context.ApplicationContext; |
74 | 76 | import org.springframework.context.annotation.Bean;
|
75 | 77 | import org.springframework.context.annotation.Configuration;
|
76 | 78 | import org.springframework.context.annotation.Role;
|
| 79 | +import org.springframework.context.annotation.Scope; |
77 | 80 | import org.springframework.context.event.EventListener;
|
78 | 81 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
79 | 82 | import org.springframework.core.MethodParameter;
|
|
179 | 182 | "annotated25", "annotated25reply1", "annotated25reply2", "annotated26", "annotated27", "annotated28",
|
180 | 183 | "annotated29", "annotated30", "annotated30reply", "annotated31", "annotated32", "annotated33",
|
181 | 184 | "annotated34", "annotated35", "annotated36", "annotated37", "foo", "manualStart", "seekOnIdle",
|
182 |
| - "annotated38", "annotated38reply", "annotated39", "annotated40", "annotated41" }) |
| 185 | + "annotated38", "annotated38reply", "annotated39", "annotated40", "annotated41", "annotated42" }) |
183 | 186 | @TestPropertySource(properties = "spel.props=fetch.min.bytes=420000,max.poll.records=10")
|
184 | 187 | public class EnableKafkaIntegrationTests {
|
185 | 188 |
|
@@ -981,6 +984,14 @@ public void testContentConversion() throws InterruptedException {
|
981 | 984 | assertThat(this.listener.contentFoo).isEqualTo(new Foo("bar"));
|
982 | 985 | }
|
983 | 986 |
|
| 987 | + @Test |
| 988 | + void proto(@Autowired ApplicationContext context) { |
| 989 | + this.registry.setAlwaysStartAfterRefresh(false); |
| 990 | + context.getBean(ProtoListener.class); |
| 991 | + assertThat(this.registry.getListenerContainer("proto").isRunning()).isFalse(); |
| 992 | + this.registry.setAlwaysStartAfterRefresh(true); |
| 993 | + } |
| 994 | + |
984 | 995 | @Configuration
|
985 | 996 | @EnableKafka
|
986 | 997 | @EnableTransactionManagement(proxyTargetClass = true)
|
@@ -1710,6 +1721,20 @@ String barInfo() {
|
1710 | 1721 | return "info for the bar listener";
|
1711 | 1722 | }
|
1712 | 1723 |
|
| 1724 | + @Bean |
| 1725 | + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) |
| 1726 | + ProtoListener proto() { |
| 1727 | + return new ProtoListener(); |
| 1728 | + } |
| 1729 | + |
| 1730 | + } |
| 1731 | + |
| 1732 | + static class ProtoListener { |
| 1733 | + |
| 1734 | + @KafkaListener(id = "proto", topics = "annotated-42", autoStartup = "false") |
| 1735 | + public void listen(String in) { |
| 1736 | + } |
| 1737 | + |
1713 | 1738 | }
|
1714 | 1739 |
|
1715 | 1740 | @Component
|
|
0 commit comments