1

Let say some piece of code took a connection from the pool and did not return it back to the pool.

I want to know if there is any setting in liberty which will force a connection back to the pool if no activity is identified on the connection after some idle time, may be 10 seconds.

I am using liberty 8.5.5.9

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
Krishna Chaitanya
  • 2,533
  • 4
  • 40
  • 74

1 Answers1

5

Websphere Liberty does not have any mechanism that will force in-use connections back to the pool after a certain amount of time.

The closest thing to this behavior would be the "transaction timeout" (default of 120s) which will timeout global transactions after the timeout is reached, and all resources in the global transaction will be cleaned up.

However, by default WebSphere will always clean up leaked connections after the transaction scope ends (be it a Local Transaction Containment or a Global Transaction).

For example, if I do the following in a servlet:

Connection conn = ds.getConnection();
// conn never closed!

The connection would be automatically closed and returned to the connection pool when the servlet request ends.

If you do a similar thing in a global transaction:

tx.begin();
Connection conn = ds.getConnection();
// conn never closed!
// tx never ended!

The global transaction will be ended and resources will be rolled back.

So as long as you don't have long-running service requests, the default cleanup behavior should give you the behavior you are looking for. If you do have long running service requests, then you may want to consider tuning the transaction timeout.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
  • Out of curiosity, I want to know if is there any such setting in websphere application server which can force the connections back? – Krishna Chaitanya Mar 22 '17 at 02:31
  • 2
    Isn't that answered above quite explicitly? – covener Mar 22 '17 at 11:21
  • @KrishnaChaitanya when you say "is there any such setting in websphere application server" are you referring to WebSphere Liberty or Traditional? Your question is tagged as "liberty" so I assumed Liberty. If you are curious about WebSphere Traditional, the behavior is the same as it is in Liberty. – Andy Guibert Mar 22 '17 at 16:52
  • Thank you. My original question was for liberty. But I got curious about traditional also. – Krishna Chaitanya Mar 22 '17 at 16:58