How to validate IBM MQ connection for Pool

447 Views Asked by At

I am developing IBM MQ Connection pool using Apache commons pool (2.4.2 ). IBM MQ JAR version 8.

As part of Pool concept , I need to validate the connection before return to program.

Help me on how to validate IBM MQ connection ?

 Java 8 
 IBM MQ 8  
 Apache commons pool 2.4.2
 JMS 2.0
1

There are 1 best solutions below

1
On

I assume you are using version 2 of Commons pool. To validate instances before delivering them to pool clients, you need to:

  1. Implement valiateObject() in your PooledObjectFactory.
  2. Set the pool's testOnBorrow and / or testOnCreate property to true.

Setting testOnBorrow to true causes instances to be validated each time they are borrowed from the pool. testOnCreate (new in Pool 2) validates only once, when the instance is created.