Search code examples
spring-integrationtcpclienttcp

Spring Integration - Is it Possible for TCP Server to disconnect selective clients


I am implementing Spring Integration (4.x Release) TCP server in my application. Where multiple clients will connect to my TCP server port. My applicaiton will start receiving multiple requests and there is one scenario where my TCP server should disconnect one of its TCP client keeping the conneciton alive with other clients. I am able to get the openConnectionIds from server conneciton factory but not able to disconnect the selected client.

How to disconnect one of the TCP clients to TCP server ports.


Solution

  • There's a method on the connection factory that allows you to close the connection using its ID...

    /**
     * Close a connection with the specified connection id.
     * @param connectionId the connection id.
     * @return true if the connection was closed.
     */
    public boolean closeConnection(String connectionId) {