java配置与tcp出站网关的等效性是什么?
我有以下spring集成XML配置java配置与tcp出站网关的等效性是什么?,java,spring,spring-integration,spring-java-config,Java,Spring,Spring Integration,Spring Java Config,我有以下spring集成XML配置 <ip:tcp-outbound-gateway id="outboundClient" request-channel="requestChannel" reply-channel="string2ObjectChannel" connection-factory="clientConnectionFactory" request-timeout="10000" reply
<ip:tcp-outbound-gateway id="outboundClient"
request-channel="requestChannel"
reply-channel="string2ObjectChannel"
connection-factory="clientConnectionFactory"
request-timeout="10000"
reply-timeout="10000"/>
但是我找不到设置请求通道的方法。
任何帮助都将不胜感激
谢谢您的配置看起来不错,但您还应该知道,任何Spring集成使用者组件都由两个主要对象组成:
MessageHandler
(TcpOutboundGateway
)和EventDrivenConsumer
用于subscribable
input channel
或PollingConsumer
如果input channel
是可轮询的
所以,既然你已经有了第一个,处理,你需要另一个消费部分。为此,Spring Integration建议使用端点注释标记@Bean
:
@Bean
@ServiceActivator(inputChannel = "requestChannel")
public TcpOutboundGateway outboundClient() {
更多信息请参阅
然而,要允许这样的注释过程(或任何其他Spring集成基础设施),您必须使用@EnableIntegration
标记您的@配置
也考虑使用从JavaCon Fig.I/P>获得更多的收益。您还需要调用方法<代码>事后属性()>代码>,这将不使用任何注册转换器通过<代码>转换服务< /代码>。我解决这类问题的方法是看源代码,因为spring在幕后发挥了很大的魔力。我看了源代码,但没有办法设置请求通道。起初我以为OutputChannel是请求通道,但setReplyChannel实际上是在内部设置OutputChannel。谢谢你的回答,但我在添加@ServiceActivator后又遇到了一个错误,它说org.springframework.messaging.MessageDeliveryException:Dispatcher没有频道“org.springframework.context.annotation”的订户。AnnotationConfigApplicationContext@7b306b9f.requestChannel'.; 嵌套的异常是org.springframework.integration.MessageDispatchingException:Dispatcher没有订阅服务器。似乎无论我在
@ServiceActivator
或@Transformer
上作为inputChannel放置什么,bean都没有订阅该频道。很好!抱歉:我没有提到@enableeintegration
。请参阅我对答案的编辑。谢谢@artem bilan,最后我发现我忘了放置@配置注释。我最初使用主Java配置中的@ImportResource
创建了spring集成XML配置,然后开始创建spring集成XML配置的Java版本,并从主配置导入。我把@enableeintegration
和@IntegrationComponentScan
放进去了,但是我忘了把@配置放进去了。有趣的是,这些配置上的@Bean
是由spring上下文创建的。这就是为什么我没有意识到我忘了把@Configuration
放在我检查应用程序的方法是,我有一组与XML配置一起工作的集成测试,所以我只是继续运行这些测试,看看java配置是否正常工作。
@Bean
@ServiceActivator(inputChannel = "requestChannel")
public TcpOutboundGateway outboundClient() {