我尝试连接两个队列通道(由JDBC Store支持)。
@Configuration
public class DemoIntegration {
@Bean
public IntegrationFlow flow(MessageChannel firstJDBCChannel,
MessageChannel secondJDBCChannel) {
return IntegrationFlows.from(firstJDBCChannel)
.bridge(bridgeHandler -> bridgeHandler.poller(p -> p.fixedDelay(100L)))
.handle(secondJDBCChannel)
.get();
}
}
我试图在这两个频道之间加入不同的结构,但仍然有一个错误:
引起:java.lang.IllegalArgumentException:发现含糊不清 方法匹配的参数类型[类java.lang.Void]:[public 布尔 org.springframework.integration.channel.AbstractPollableChannel.removeInterceptor(org.springframework.messaging.support.ChannelInterceptor), public org.springframework.messaging.Message org.springframework.integration.channel.AbstractPollableChannel.receive(长), 公众最终无效 org.springframework.integration.context.IntegrationObjectSupport.setPrimaryExpression(org.springframework.expression.Expression), 公共无效 org.springframework.integration.channel.AbstractMessageChannel.setStatsEnabled(布尔值), 公共无效 org.springframework.integration.channel.AbstractMessageChannel.setMessageConverter(org.springframework.messaging.converter.MessageConverter), 公共无效 org.springframework.integration.channel.AbstractMessageChannel.setDatatypes(java.lang.Class中...) 公共无效 org.springframework.integration.channel.AbstractMessageChannel.configureMetrics(org.springframework.integration.support.management.AbstractMessageChannelMetrics), 公共无效 org.springframework.integration.context.IntegrationObjectSupport.setComponentName(java.lang.String中), public org.springframework.messaging.support.ChannelInterceptor org.springframework.integration.channel.AbstractPollableChannel.removeInterceptor(INT), 公共无效 org.springframework.integration.context.IntegrationObjectSupport.setMessageBuilderFactory(org.springframework.integration.support.MessageBuilderFactory), public java.util.List> org.springframework.integration.channel.QueueChannel.purge(org.springframework.integration.core.MessageSelector), 公共无效 org.springframework.integration.context.IntegrationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext) 抛出org.springframework.beans.BeansException,public void org.springframework.integration.context.IntegrationObjectSupport.setBeanFactory(org.springframework.beans.factory.BeanFactory), public org.springframework.expression.Expression org.springframework.integration.context.IntegrationObjectSupport.getExpression() 公共无效 org.springframework.integration.channel.AbstractPollableChannel.setInterceptors(java.util.List中), 公共无效 org.springframework.integration.context.IntegrationObjectSupport.setChannelResolver(org.springframework.messaging.core.DestinationResolver)] 在org.springframework.util.Assert.isNull(Assert.java:155) 〜[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE] at org.springframework.integration.util.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:776) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.util.MessagingMethodInvokerHelper。(MessagingMethodInvokerHelper.java:379) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.util.MessagingMethodInvokerHelper。(MessagingMethodInvokerHelper.java:225) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.util.MessagingMethodInvokerHelper。(MessagingMethodInvokerHelper.java:220) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.handler.MethodInvokingMessageProcessor。(MethodInvokingMessageProcessor.java:60) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.handler.ServiceActivatingHandler。(ServiceActivatingHandler.java:38) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:924) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:904) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:891) 〜[spring-integration-core-5.0.0.RC1.jar:5.0.0.RC1] at name.karwowski.blazej.integrationdemo2.DemoIntegration.flow(DemoIntegration.java:16) 〜[classes /:na] at name.karwowski.blazej.integrationdemo2.DemoIntegration $$ EnhancerBySpringCGLIB $$ f82aadc3.CGLIB $ $流动0() 〜[classes /:na] at name.karwowski.blazej.integrationdemo2.DemoIntegration $$ EnhancerBySpringCGLIB $$ f82aadc3 $$ FastClassBySpringCGLIB $$ ef9b4b0c.invoke() 〜[classes /:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) 〜[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) 〜[spring-context-5.0.1.RELEASE.jar:5.0.1.RELEASE] at name.karwowski.blazej.integrationdemo2.DemoIntegration $$ EnhancerBySpringCGLIB $$ f82aadc3.flow() 〜[classes /:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)〜[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 〜[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 〜[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) 〜[na:1.8.0_151] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:155) 〜[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE] ... 19个常见帧 省略
如何正确连接两个(或更多)队列通道?我需要在它们之间进行一些处理,并允许应用程序在停止时保留消息。
完整的日志和代码示例在github上:https://github.com/blazejkarwowski/integration-test
答案 0 :(得分:2)
而不是.handle(secondJDBCChannel)
,您必须使用.channel(secondJDBCChannel)
。没有什么可以处理的 - 它介于两者之间。
有关详细信息,请参阅Reference Manual 。