com.ibm.mq

Class MQSimpleConnectionManager

  1. java.lang.Object
  2. extended bycom.ibm.mq.jmqi.JmqiObject
  3. extended bycom.ibm.mq.MQSimpleConnectionManager

  1. public final class MQSimpleConnectionManager
  2. extends com.ibm.mq.jmqi.JmqiObject
An MQSimpleConnectionManager provides basic connection pooling function. You can use an MQSimpleConnectionManager either as the default connection manager, or as a parameter to an MQQueueManager constructor. When an MQQueueManager is constructed, the most recently used connection in the pool is used. Connections are destroyed by a separate thread when they are unused for a specified period, when there are more than a specified number of unused connections in the pool, or when the maximum number of connections has been reached and room must be made for new connections. You can specify the timeout period, the maximum number of managed connections, and the maximum number of unused connections.

Field Summary

Modifier and Type Field and Description
  1. static
  2. int
MODE_ACTIVE
The pool is always active.
  1. static
  2. int
MODE_AUTO
An MQSimpleConnectionManager is active if it is the default connection manager and there is at least one connection in the pool.
  1. static
  2. int
MODE_INACTIVE
The pool is always inactive.
Fields inherited from class com.ibm.mq.jmqi.JmqiObject
COMP_JM, COMP_JN, COMP_JO

Constructor Summary

Constructor and Description
MQSimpleConnectionManager()
Constructs an MQSimpleConnectionManager.

Method Summary

Modifier and Type Method and Description
  1. java.lang.Object
allocateConnection(com.ibm.mq.MQManagedConnectionFactory mcf,javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
Makes a connection to a queue manager, either by reusing an existing connection or by creating a new one.
  1. java.lang.Object
createConnection(com.ibm.mq.MQManagedConnectionFactory mcf,javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
Makes a connection to a queue manager.
  1. int
getActive()
Gets the active mode of the pool.
  1. int
getHighThreshold()
Deprecated. use getMaxUnusedConnections()instead.
  1. int
getMaxConnections()
Gets the maximum number of connections.
  1. int
getMaxUnusedConnections()
Gets the maximum number of unused connections in the pool.
  1. long
getTimeout()
Gets the timeout value.
  1. java.lang.Object
recycleConnection(com.ibm.mq.MQManagedConnectionFactory mcf,javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
Finds an existing connection to a queue manager.
  1. void
setActive(int mode)
Sets the active mode of the pool.
  1. void
setHighThreshold(int limit)
Deprecated. use setMaxUnusedConnections() instead.
  1. void
setMaxConnections(int newLimit)
Sets the maximum number of connections.
  1. void
setMaxUnusedConnections(int limit)
Sets the maximum number of unused connections in the pool.
  1. void
setTimeout(long timeout)
Sets the timeout value.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

MODE_AUTO

  1. public static final int MODE_AUTO
An MQSimpleConnectionManager is active if it is the default connection manager and there is at least one connection in the pool.

This is the default mode.

See Also:

MODE_ACTIVE

  1. public static final int MODE_ACTIVE
The pool is always active. On MQQueueManager.disconnect(), the underlying connection is pooled and can be reused the next time an MQQueueManager object is constructed. Connections are destroyed by a separate thread if they have been unused for longer then the timeout period or if the size of the pool exceeds the value set by setMaxUnusedConnections().
See Also:

MODE_INACTIVE

  1. public static final int MODE_INACTIVE
The pool is always inactive. The pool of connections is cleared on entering this mode. The connection underlying any active MQQueueManager objects is destroyed when MQQueueManager.disconnect()is called.
See Also:

Constructor Detail

MQSimpleConnectionManager

  1. public MQSimpleConnectionManager( )
Constructs an MQSimpleConnectionManager.

Method Detail

allocateConnection

  1. public java.lang.Object allocateConnection( com.ibm.mq.MQManagedConnectionFactory mcf,
  2. javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
  3. throws javax.resource.ResourceException
Makes a connection to a queue manager, either by reusing an existing connection or by creating a new one. It is called by the connection factory instance of the resource adapter.

Normal applications must not call this method.

Parameters:
mcf - the connection factory.
cxRequestInfo - represents information specific to the resource adapter for handling the connection request.
Returns:
a connection.
Throws:
javax.resource.ResourceException - if the call fails.

recycleConnection

  1. public java.lang.Object recycleConnection( com.ibm.mq.MQManagedConnectionFactory mcf,
  2. javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
Finds an existing connection to a queue manager. It is called by the connection factory instance of the resource adapter.

Normal applications must not call this method.

Parameters:
mcf - the connection factory.
cxRequestInfo - represents information specific to the resource adapter for handling the connection request.
Returns:
a connection, or null if the call fails.

createConnection

  1. public java.lang.Object createConnection( com.ibm.mq.MQManagedConnectionFactory mcf,
  2. javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
  3. throws javax.resource.ResourceException
Makes a connection to a queue manager. It is called by the connection factory instance of the resource adapter.

Normal applications must not call this method.

Parameters:
mcf - the connection factory.
cxRequestInfo - represents information specific to the resource adapter for handling the connection request.
Returns:
a connection.
Throws:
javax.resource.ResourceException - if the call fails.

setActive

  1. public void setActive(int mode)
Sets the active mode of the pool.
Parameters:

getActive

  1. public int getActive()
Gets the active mode of the pool.
Returns:

setTimeout

  1. public void setTimeout(long timeout)
Sets the timeout value.
Parameters:
timeout - the time out value in milliseconds. Connections which have been unused for this length of time are destroyed.

getTimeout

  1. public long getTimeout()
Gets the timeout value.
Returns:
the time out value in milliseconds. Connections that have been unused for this length of time are destroyed.

setMaxUnusedConnections

  1. public void setMaxUnusedConnections( int limit)
Sets the maximum number of unused connections in the pool.
Parameters:
limit - recently used connections are destroyed if the size of the pool exceeds this value.

setHighThreshold

  1. public void setHighThreshold(int limit)
Deprecated. use setMaxUnusedConnections() instead.
Set the max threshold limit for unused connections
Parameters:
limit - The value to set

getMaxUnusedConnections

  1. public int getMaxUnusedConnections( )
Gets the maximum number of unused connections in the pool.
Returns:
the maximum number of unused connections.

getHighThreshold

  1. public int getHighThreshold()
Deprecated. use getMaxUnusedConnections()instead.
Get the max threshold limit of unused connections
Returns:
int The high threshold value

setMaxConnections

  1. public void setMaxConnections(int newLimit)
  2. throws java.lang.IllegalArgumentException
Sets the maximum number of connections.
Parameters:
newLimit - the new maximum number of connections.
Throws:
java.lang.IllegalArgumentException - If limit specified is illegal

getMaxConnections

  1. public int getMaxConnections()
Gets the maximum number of connections.
Returns:
the maximum number of connections.