|
74 | 74 | import org.springframework.beans.factory.annotation.Autowired; |
75 | 75 | import org.springframework.beans.factory.config.BeanDefinition; |
76 | 76 | import org.springframework.beans.factory.config.BeanPostProcessor; |
| 77 | +import org.springframework.beans.factory.config.ConfigurableBeanFactory; |
| 78 | +import org.springframework.context.ApplicationContext; |
77 | 79 | import org.springframework.context.annotation.Bean; |
78 | 80 | import org.springframework.context.annotation.Configuration; |
79 | 81 | import org.springframework.context.annotation.Role; |
| 82 | +import org.springframework.context.annotation.Scope; |
80 | 83 | import org.springframework.context.event.EventListener; |
81 | 84 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; |
82 | 85 | import org.springframework.core.MethodParameter; |
|
181 | 184 | "annotated25", "annotated25reply1", "annotated25reply2", "annotated26", "annotated27", "annotated28", |
182 | 185 | "annotated29", "annotated30", "annotated30reply", "annotated31", "annotated32", "annotated33", |
183 | 186 | "annotated34", "annotated35", "annotated36", "annotated37", "foo", "manualStart", "seekOnIdle", |
184 | | - "annotated38", "annotated38reply", "annotated39", "annotated40", "annotated41" }) |
| 187 | + "annotated38", "annotated38reply", "annotated39", "annotated40", "annotated41", "annotated42" }) |
185 | 188 | @TestPropertySource(properties = "spel.props=fetch.min.bytes=420000,max.poll.records=10") |
186 | 189 | public class EnableKafkaIntegrationTests { |
187 | 190 |
|
@@ -988,6 +991,14 @@ public void testContentConversion() throws InterruptedException { |
988 | 991 | assertThat(this.listener.contentFoo).isEqualTo(new Foo("bar")); |
989 | 992 | } |
990 | 993 |
|
| 994 | + @Test |
| 995 | + void proto(@Autowired ApplicationContext context) { |
| 996 | + this.registry.setAlwaysStartAfterRefresh(false); |
| 997 | + context.getBean(ProtoListener.class); |
| 998 | + assertThat(this.registry.getListenerContainer("proto").isRunning()).isFalse(); |
| 999 | + this.registry.setAlwaysStartAfterRefresh(true); |
| 1000 | + } |
| 1001 | + |
991 | 1002 | @Configuration |
992 | 1003 | @EnableKafka |
993 | 1004 | @EnableTransactionManagement(proxyTargetClass = true) |
@@ -1704,6 +1715,20 @@ String barInfo() { |
1704 | 1715 | return "info for the bar listener"; |
1705 | 1716 | } |
1706 | 1717 |
|
| 1718 | + @Bean |
| 1719 | + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) |
| 1720 | + ProtoListener proto() { |
| 1721 | + return new ProtoListener(); |
| 1722 | + } |
| 1723 | + |
| 1724 | + } |
| 1725 | + |
| 1726 | + static class ProtoListener { |
| 1727 | + |
| 1728 | + @KafkaListener(id = "proto", topics = "annotated-42", autoStartup = "false") |
| 1729 | + public void listen(String in) { |
| 1730 | + } |
| 1731 | + |
1707 | 1732 | } |
1708 | 1733 |
|
1709 | 1734 | @Component |
|
0 commit comments