|
49 | 49 | import javax.validation.ValidationException; |
50 | 50 | import javax.validation.constraints.Max; |
51 | 51 |
|
| 52 | +import org.aopalliance.intercept.MethodInterceptor; |
| 53 | +import org.aopalliance.intercept.MethodInvocation; |
52 | 54 | import org.apache.commons.logging.Log; |
53 | 55 | import org.apache.commons.logging.LogFactory; |
54 | 56 | import org.apache.kafka.clients.admin.NewTopic; |
|
67 | 69 | import org.junit.jupiter.api.Test; |
68 | 70 | import org.mockito.Mockito; |
69 | 71 |
|
| 72 | +import org.springframework.aop.framework.ProxyFactory; |
| 73 | +import org.springframework.beans.BeansException; |
70 | 74 | import org.springframework.beans.factory.ObjectProvider; |
71 | 75 | import org.springframework.beans.factory.annotation.Autowired; |
| 76 | +import org.springframework.beans.factory.config.BeanDefinition; |
| 77 | +import org.springframework.beans.factory.config.BeanPostProcessor; |
72 | 78 | import org.springframework.context.annotation.Bean; |
73 | 79 | import org.springframework.context.annotation.Configuration; |
74 | 80 | import org.springframework.context.annotation.Primary; |
| 81 | +import org.springframework.context.annotation.Role; |
75 | 82 | import org.springframework.context.event.EventListener; |
76 | 83 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; |
77 | 84 | import org.springframework.core.MethodParameter; |
| 85 | +import org.springframework.core.Ordered; |
| 86 | +import org.springframework.core.annotation.Order; |
78 | 87 | import org.springframework.core.convert.converter.Converter; |
79 | 88 | import org.springframework.data.web.JsonPath; |
80 | 89 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; |
|
169 | 178 | "annotated25", "annotated25reply1", "annotated25reply2", "annotated26", "annotated27", "annotated28", |
170 | 179 | "annotated29", "annotated30", "annotated30reply", "annotated31", "annotated32", "annotated33", |
171 | 180 | "annotated34", "annotated35", "annotated36", "annotated37", "foo", "manualStart", "seekOnIdle", |
172 | | - "annotated38", "annotated38reply", "annotated39"}) |
| 181 | + "annotated38", "annotated38reply", "annotated39", "sentto-in", "sendto-out"}) |
173 | 182 | public class EnableKafkaIntegrationTests { |
174 | 183 |
|
175 | 184 | private static final String DEFAULT_TEST_GROUP_ID = "testAnnot"; |
@@ -1278,6 +1287,13 @@ public IfaceListener<String> ifaceListener() { |
1278 | 1287 | return new IfaceListenerImpl(); |
1279 | 1288 | } |
1280 | 1289 |
|
| 1290 | + @Bean |
| 1291 | + @Order(Ordered.HIGHEST_PRECEDENCE) |
| 1292 | + @Role(BeanDefinition.ROLE_INFRASTRUCTURE) |
| 1293 | + public ProxyListenerPostProcessor proxyListenerPostProcessor() { |
| 1294 | + return new ProxyListenerPostProcessor(); |
| 1295 | + } |
| 1296 | + |
1281 | 1297 | @Bean |
1282 | 1298 | public MultiListenerBean multiListener() { |
1283 | 1299 | return new MultiListenerBean(); |
@@ -2012,6 +2028,27 @@ public void registerSeekCallback(ConsumerSeekCallback callback) { |
2012 | 2028 |
|
2013 | 2029 | } |
2014 | 2030 |
|
| 2031 | + static class ProxyListenerPostProcessor implements BeanPostProcessor { |
| 2032 | + |
| 2033 | + @Override |
| 2034 | + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { |
| 2035 | + if ("multiListenerSendTo".equals(beanName)) { |
| 2036 | + ProxyFactory proxyFactory = new ProxyFactory(bean); |
| 2037 | + proxyFactory.setProxyTargetClass(true); |
| 2038 | + proxyFactory.addAdvice(new MethodInterceptor() { |
| 2039 | + @Override |
| 2040 | + public Object invoke(MethodInvocation invocation) throws Throwable { |
| 2041 | + logger.info(String.format("Proxy listener for %s.$s", |
| 2042 | + invocation.getMethod().getDeclaringClass(), invocation.getMethod().getName())); |
| 2043 | + return invocation.proceed(); |
| 2044 | + } |
| 2045 | + }); |
| 2046 | + return proxyFactory.getProxy(); |
| 2047 | + } |
| 2048 | + return bean; |
| 2049 | + } |
| 2050 | + } |
| 2051 | + |
2015 | 2052 | public static class SeekToLastOnIdleListener extends AbstractConsumerSeekAware { |
2016 | 2053 |
|
2017 | 2054 | private final CountDownLatch latch1 = new CountDownLatch(10); |
|
0 commit comments