I'm using tcp-connection-factory to create a tcp server. However, I need to shutdown the server or the listener sometimes. How can I do it?
I'm using tcp-connection-factory to create a tcp server. However, I need to shutdown the server or the listener sometimes. How can I do it?
Add a <control-bus/> and send a message containing "@endpointName.stop()" to it.
Or, inject the endpoint that uses the connection factory (TcpReceivingChannelAdapter or TcpInboundGateway) into one of your beans, and call stop() directly.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware
Yes; stop() will close all active connections and stop listening for any new ones. start() will start listening again.
auto-startup="false" (on the endpoint) will prevent the framework from doing an initial start()
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware
I called this.tcpinboundadapter.stop();
tcpinboundadapteris tcp-outbound-channel-adapter injected to my bean. The adapter doesn't stop listening. I'm using 2.1. I also set auto-startup to false, it's still starting up. why?
<int:control-bus input-channel="controlChannel"/>
<int-ip:tcp-inbound-channel-adapter
id="WA_InboundChannelAdapter" channel="WA_InboundChannel"
connection-factory="WA_Server" auto-startup="false"/>
I just tested it and it works fine for me; doesn't start when auto-startup="false" and starts/stops fine.
I suggest you run with debug logging to see what's happening.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware
It works in Junit testing. but in our application, I can't stop the listener with the same code. I compared the logging,
JUnit gives me the logging below.
DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'WA_InboundChannelAdapter'
WARN : org.springframework.integration.ip.tcp.connection. TcpNetServerConnectionFactory - Server Socket closed
INFO : org.springframework.integration.ip.tcp.connection. TcpNetServerConnectionFactory - stopped WA_Server
But our application, I don't see these three lines. the context file is the same. the code is the same. It appears the it couldn't find the adapter in our application. What could the possible cause of it?
It's impossible for auto-start="false" and stop() to work in one environment, but not in another, given the same versions of Spring Integration.
I suggest you add some diagnostics to your code to ensure you are running with the right configuration, and you are calling stop().
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware