apache-commons-pool

How to return objects to the Pool by timeout using apache commons pool

馋奶兔 提交于 2020-01-01 11:40:08
问题 I'm using Apache Commons Pool library to maintaing a pool of couchbase connections (can be seen as any kind of connection, doesn't really matter). The problem I'm facing is that the only way I've found to return objects to the pool is to do it programmatically by calling the returnObject method from the GenericObjectPool class. This forces the application to guarantee the return of the object once is borrowed from the pool, regardless any exception or unexpected behavior in the application.

How to return objects to the Pool by timeout using apache commons pool

亡梦爱人 提交于 2020-01-01 11:40:07
问题 I'm using Apache Commons Pool library to maintaing a pool of couchbase connections (can be seen as any kind of connection, doesn't really matter). The problem I'm facing is that the only way I've found to return objects to the pool is to do it programmatically by calling the returnObject method from the GenericObjectPool class. This forces the application to guarantee the return of the object once is borrowed from the pool, regardless any exception or unexpected behavior in the application.

JMS Connection Pooling in Message Listener

落爺英雄遲暮 提交于 2019-12-13 20:28:03
问题 Currently i'm working on a standalone Java apps that connects to a Websphere MQ to send and receive messages. The flow is in asynchronous mode, which we implemented using MessageListener class to retrieve the messages from the queue when they are ready. The code to initialize the consumer with the listener is as follow: if(connection == null) connection = getJmsConnection(); try { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); if (isTopic) { destination = session

How to shutdown a GenericKeyedObjectPool safely?

这一生的挚爱 提交于 2019-12-11 11:07:47
问题 I have a GenericKeyedObjectPool in my application. I can close it with the close method but how should I wait for the clients to return (and the pool destroys) every borrowed object to the pool? I need something like ExecutorService.awaitTermination. 回答1: Create a wrapper for the GenericKeyedObjectPool which has the required awaitTermination method. You can check the close and the returnObject calls and decrement a latch if the pool is closed and every object was returned (= the total number

How to return objects to the Pool by timeout using apache commons pool

梦想的初衷 提交于 2019-12-04 08:59:42
I'm using Apache Commons Pool library to maintaing a pool of couchbase connections (can be seen as any kind of connection, doesn't really matter). The problem I'm facing is that the only way I've found to return objects to the pool is to do it programmatically by calling the returnObject method from the GenericObjectPool class. This forces the application to guarantee the return of the object once is borrowed from the pool, regardless any exception or unexpected behavior in the application. Even though I'm controlling the return of the objects to the pool in the whole application, I find risky