Skip to content

TCP Client Connection Factory Improvements #2866

Open

Description

@garyrussell

Add getConnection(String connectionId) so the client can select which connection it wants (if not open, return null).

Also singleUse serves 2 purposes when true

  • tells the CF to hand out a new connection each time getConnection() is called
  • tells the adapters to close the socket when the send/receive is complete (one-way) or after the reply is sent/received (request/reply).

Split this into two flags sharedConnection and closeAfterCompletion.

See https://stackoverflow.com/questions/55404438/programmatically-create-multiple-connections-for-tcpnetclientconnectionfactory/55404817#55404817

Activity

  1. added this to the milestone on Mar 28, 2019
  2. self-assigned this
    on Mar 28, 2019
  3. modified the milestones: , 5.3 RC1, Backlog on Mar 31, 2020
  4. deepak5127 commented on Sep 10, 2020

    @deepak5127
    Contributor

    Hi @garyrussell , Shall i work on this item ?

  5. artembilan commented on Sep 10, 2020

    @artembilan
    Member

    @deepak5127 ,

    sure! You can take a crack on this and we together can see what to do else in your Pull Request!

  6. deepak5127 commented on Oct 14, 2020

    @deepak5127
    Contributor

    @artembilan I have couple of questions.

    1. Should i replace singleUse boolean with two boolean flags? Like replace singleUse in AbstractConnectionFactory with two booleans mentioned above ?
    2. If so it have changes in both client and server factory classes. Also if i understand correctly, we need to use sharedConnection in connection factory for creating / re-using the connections and closeAfterCompletion in adapters to close/keep the connections ?
    3. Also new method getConnection(String connectionId) , should we implement for ThreadAffinityClientConnectionFactory and CachingClientConnectionFactory alone ?
  7. garyrussell commented on Oct 15, 2020

    @garyrussell
    ContributorAuthor
    1. Yes; but we need to keep (and deprecate) the getter and setter for the old flag (and set both).
    2. Correct.
    3. No; it should be implemented by all client factories; the adapters will need a mechanism to decide which connection id to obtain.

    This is a non-trivial change (hence it's been on the backlog for a while).

  8. deepak5127 commented on Oct 15, 2020

    @deepak5127
    Contributor

    Thanks @garyrussell . Just to make sure I understand correctly. Instead of calling "this.clientConnectionFactory.getConnection() " from adapters, now we should extract the ip_connectionId from message and call this.clientConnectionFactory.getConnection(connectionId).

    If the connection is already created , then send that back or create a new one. Also we need to create a Map in AbstractClientConnectionFactory to hold multiple connections, since we dont have that.

  9. garyrussell commented on Oct 15, 2020

    @garyrussell
    ContributorAuthor

    No; it should be optional only; by default use the existing getConnection().

    Add a SpEL expression property; something like connectionIdExpression; which, if present, tells us to try to get the existing connection by name and, if not present, fall back to the existing getConnection() - we might also need. to provide an option to throw an exception if the connection doesn't exist already.

    In most cases, yes, the expression will be headers[ip_connectionId].

    Yes, we'll need a map of connections.

  10. deepak5127 commented on Oct 15, 2020

    @deepak5127
    Contributor

    Thanks @garyrussell . I will work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions