|
144 | 144 | import org.springframework.retry.support.RetryTemplate;
|
145 | 145 | import org.springframework.stereotype.Component;
|
146 | 146 | import org.springframework.test.annotation.DirtiesContext;
|
| 147 | +import org.springframework.test.context.TestPropertySource; |
147 | 148 | import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
148 | 149 | import org.springframework.transaction.PlatformTransactionManager;
|
149 | 150 | import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
177 | 178 | "annotated29", "annotated30", "annotated30reply", "annotated31", "annotated32", "annotated33",
|
178 | 179 | "annotated34", "annotated35", "annotated36", "annotated37", "foo", "manualStart", "seekOnIdle",
|
179 | 180 | "annotated38", "annotated38reply", "annotated39", "annotated40", "annotated41" })
|
| 181 | +@TestPropertySource(properties = "spel.props=fetch.min.bytes=420000,max.poll.records=10") |
180 | 182 | public class EnableKafkaIntegrationTests {
|
181 | 183 |
|
182 | 184 | private static final String DEFAULT_TEST_GROUP_ID = "testAnnot";
|
@@ -350,6 +352,10 @@ public void testSimple() throws Exception {
|
350 | 352 | .isEqualTo("fiz");
|
351 | 353 | assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.clientId"))
|
352 | 354 | .isEqualTo("clientIdViaAnnotation-0");
|
| 355 | + assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.fetcher.maxPollRecords")) |
| 356 | + .isEqualTo(10); |
| 357 | + assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.fetcher.minBytes")) |
| 358 | + .isEqualTo(420000); |
353 | 359 |
|
354 | 360 | MessageListenerContainer rebalanceConcurrentContainer = registry.getListenerContainer("rebalanceListener");
|
355 | 361 | assertThat(rebalanceConcurrentContainer).isNotNull();
|
@@ -488,6 +494,10 @@ public void testJson() throws Exception {
|
488 | 494 | assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
|
489 | 495 | "listenerConsumer.consumer.groupId", Optional.class).get())
|
490 | 496 | .isEqualTo("buz.explicitGroupId");
|
| 497 | + assertThat(KafkaTestUtils.getPropertyValue(buzContainer, "listenerConsumer.consumer.fetcher.maxPollRecords")) |
| 498 | + .isEqualTo(5); |
| 499 | + assertThat(KafkaTestUtils.getPropertyValue(buzContainer, "listenerConsumer.consumer.fetcher.minBytes")) |
| 500 | + .isEqualTo(123456); |
491 | 501 | }
|
492 | 502 |
|
493 | 503 | @Test
|
@@ -1649,6 +1659,11 @@ protected Object convertToInternal(Object payload, @Nullable MessageHeaders head
|
1649 | 1659 | };
|
1650 | 1660 | }
|
1651 | 1661 |
|
| 1662 | + @Bean |
| 1663 | + List<String> buzProps() { |
| 1664 | + return List.of("max.poll.records: 5", "fetch.min.bytes: 123456"); |
| 1665 | + } |
| 1666 | + |
1652 | 1667 | }
|
1653 | 1668 |
|
1654 | 1669 | @Component
|
@@ -1845,14 +1860,14 @@ public void eventHandler(ListenerContainerNoLongerIdleEvent event) {
|
1845 | 1860 | @TopicPartition(topic = "annotated6", partitions = "0",
|
1846 | 1861 | partitionOffsets = @PartitionOffset(partition = "${xxx:1}", initialOffset = "${yyy:0}",
|
1847 | 1862 | relativeToCurrent = "${zzz:true}"))
|
1848 |
| - }, clientIdPrefix = "${foo.xxx:clientIdViaAnnotation}") |
| 1863 | + }, clientIdPrefix = "${foo.xxx:clientIdViaAnnotation}", properties = "#{'${spel.props}'.split(',')}") |
1849 | 1864 | public void listen5(ConsumerRecord<?, ?> record) {
|
1850 | 1865 | this.capturedRecord = record;
|
1851 | 1866 | this.latch5.countDown();
|
1852 | 1867 | }
|
1853 | 1868 |
|
1854 | 1869 | @KafkaListener(id = "buz", topics = "annotated10", containerFactory = "kafkaJsonListenerContainerFactory",
|
1855 |
| - groupId = "buz.explicitGroupId") |
| 1870 | + groupId = "buz.explicitGroupId", properties = "#{@buzProps}") |
1856 | 1871 | public void listen6(Foo foo) {
|
1857 | 1872 | this.foo = foo;
|
1858 | 1873 | this.latch6.countDown();
|
|
0 commit comments