Spring integration 正在使用客户端连接工厂停止TCP适配器

Spring integration 正在使用客户端连接工厂停止TCP适配器,spring-integration,spring-integration-dsl,Spring Integration,Spring Integration Dsl,我正在尝试使用控制总线命令,即@AdapterID.stop() 创建流的代码如下所示: IntegrationFlow flow = IntegrationFlows.from(Tcp.inboundAdapter(Tcp.nioClient("127.0.0.1",3226)) .serializer(customSerializer) .deserializer(customSerializer) .id("a

我正在尝试使用控制总线命令,即
@AdapterID.stop()
创建流的代码如下所示:

 IntegrationFlow flow = IntegrationFlows.from(Tcp.inboundAdapter(Tcp.nioClient("127.0.0.1",3226))
             .serializer(customSerializer)
             .deserializer(customSerializer)
             .id("abc")).clientMode(true).retryInterval(1000).errorChannel("testChannel"))
             .enrichHeaders(f->f.header("abc","abc"))
             .channel(directChannel())
             .handle(Jms.outboundAdapter(ConnectionFactory())
             .destination(hostConnection.getConnectionNumber()))
             .get();

     theFlow = this.flowContext.registration(flow).id("out.flow").register(); 
当我使用控制总线作为停止适配器时:

 public String stopConnectionAdapter(String connectionName) {
    MessageChannel controlChannel = ac.getBean("controlBus.input", MessageChannel.class); 
    String exp = "@"+connectionName+".stop()";
    controlChannel.send(new GenericMessage<String>(exp));
    return "STOPPED";
}
如何停止此错误并在没有任何异常和错误的情况下关闭连接

另外,以预期的方式顺序处理(运行时启动和停止)这些连接(集成流组件)而不发生任何错误的有效方法是什么?

这里的罪魁祸首是
。clientMode(true)
。我正在尝试停止流定义中id为“abc”的ConnectionFactory
.id(“abc”).clientMode(true).retryInterval(1000).errorChannel(“testChannel”))

现在,我向InboundAdapter添加了一个id,如下所示:
.id(“abc”).clientMode(true).retryInterval(1000).errorChannel(“testChannel”).id(“test”))

使用控制总线,首先关闭连接工厂,然后关闭适配器
@abc.stop()
@test.stop()
上述错误将被解决


但我仍然不知道如何有效地停止集成流,即我必须为每个组件提供唯一的ID,并使用控制总线命令逐个停止

你不应该阻止工厂;它的生命周期由适配器控制;只需停止适配器;不需要停止其他组件


您还可以
stop()
整个
IntegrationFlow
bean(
out.flow
),它将停止组件。

正确。同样的控制总线也可以在这件事上使用。
2018-06-04 11:09:45.551 ERROR 34860 --- [ask-scheduler-7] o.s.i.i.t.c.ClientModeConnectionManager  : Could not establish connection using conncr3, host=127.0.0.1, port=3226

java.io.IOException: conncr3, host=127.0.0.1, port=3226 connection factory has not been started
at org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory.checkActive(AbstractConnectionFactory.java:873) ~[spring-integration-ip-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory.checkActive(TcpNioClientConnectionFactory.java:68) ~[spring-integration-ip-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:68) ~[spring-integration-ip-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:33) ~[spring-integration-ip-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.integration.ip.tcp.connection.ClientModeConnectionManager.run(ClientModeConnectionManager.java:55) ~[spring-integration-ip-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_111]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_111]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_111]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]