Announcement Announcement Module
No announcement yet.
Is there a way to shutdown the listen created by connection factory? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there a way to shutdown the listen created by connection factory?

    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?

  • #2
    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.


    • #3
      Can we directly call stop() method, whenever we need to destroy the connection.


      • #4
        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()


        • #5
          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"/>
          id="WA_InboundChannelAdapter" channel="WA_InboundChannel"
          connection-factory="WA_Server" auto-startup="false"/>


          • #6
            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.


            • #7
              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: 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?


              • #8
                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().