简体   繁体   中英

Connection Pool for remote connections in Java

Can I use connection pool for remote connections to some VM? For example I need to execute random number of commands on random number of VM? So I dont want to open a new connection every time so Connection Pool is the solution. But I can find only examples with db? So my question is: Is it possible to use Connection Pool for remote connections and if its, could it be Hikari? Any example will be good. Thank you!

Edited: I am using ssh protocol. And I am talking about Spring Boot application.

Can connection pools be used without reference to the application protocol?

No.

  • If the application protocol depends on the closure of a connection to signal something (eg the end of a data stream), then the connections cannot be reused.
  • If the application protocol doesn't have a clean way to deal with certain kinds of application error apart from closing the connection, then connection pools may be ineffective.

Is it possible for a specific protocol?

It depends on the specific protocol.

Is it possible for remote command execution?

You haven't specified a protocol!!!

But is it possible in theory ?

One problem is that (for example) an SSH session has context such as the remote user id, the remote directory, remote environment variables and so on. In the general case, it would be unwise and unsafe to reuse a connection if you did not know what might have happened previous for that connection.

Could it be Hikari?

No. HikariCP is a connection pool for JDBC connections.

Any example will be good.

Google for "java ssh connection pool".

I found these:

(Future readers ... please do your own search ... thanks!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM