MQEnvironment

public class MQEnvironment
extends Object
java.lang.Object
   |
   +----com.ibm.mq.MQEnvironment
          

MQEnvironment contains static fields that control the environment in which an MQQueueManager object (and its corresponding connection to WebSphere MQ) is constructed. As values set in MQEnvironment class take effect when the MQQueueManager constructor is called, you must set the values in the MQEnvironment class before you construct a MQQueueManager object.

Note: All the methods and attributes of this class apply to the WebSphere MQ classes for Java client connections, but only enableTracing(), disableTracing(), properties, and version_notice apply to bindings connections.

Fields

CCSID

public static int

The CCSID used by the client. It does not apply when connecting directly to WebSphere MQ in bindings mode.

Changing this value affects the way that the queue manager you connect to translates information in the WebSphere MQ headers. All data in WebSphere MQ headers is drawn from the invariant part of the ASCII codeset, except for the data in the MQMessage.applicationIdData and MQMessage.putApplicationName fields.

If you avoid using characters from the variant part of the ASCII codeset for these two fields, then the CCSID can be changed from 819 to any other ASCII codeset.

If you change the client CCSID to be the same as that of the queue manager to which you are connecting, you gain a performance benefit at the queue manager because it does not attempt to translate the message headers.

The default value is 819.

channel

public static java.lang.String

The name of the channel to connect to on the target queue manager. It does not apply when connecting directly to WebSphere MQ in bindings mode. You must set this field, or the corresponding property, before constructing an MQQueueManager instance for use in client mode.

connOptions

public static int

The queue manager connection options. Possible values are:

connTag

public static byte[]

The connection tag which allows users to serialize access to the resources they are using on a z/OS queue manager. The connTag String is truncated to 128 bytes. connTag is ignored if connOptions is not set.

hdrCompList

public static java.util.Collection

The list of supported compressors for header compression. Possible values are:

hostname

public static java.lang.String

The TCP/IP hostname of the machine on which the WebSphere MQ server resides. If the hostname is not set, and no overriding properties are set, bindings mode is used to connect to the local queue manager.

localAddressSetting

public static java.lang.String

The local address, including a range of ports, used when connecting to a WebSphere MQ queue manager through a firewall. The format is [ip-addr][(low-port[,high-port])].

Here are some examples:

9.20.4.98
The channel binds to address 9.20.4.98 locally
9.20.4.98(1000)
The channel binds to address 9.20.4.98 locally and uses port 1000
9.20.4.98(1000,2000)
The channel binds to address 9.20.4.98 locally and uses a port in the range 1000 to 2000
(1000)
The channel binds to port 1000 locally
(1000,2000)
The channel binds to a port in the range 1000 to 2000 locally

You can specify a host name instead of an IP address. The variable is initialized from system property com.ibm.mq.localAddress when you start the JVM. The default value is null.

msgCompList

public static java.util.Collection

The list of supported compressors for message compression. Possible values are:

password

public static java.lang.String

The password used to verify the identity of the WebSphere MQ Client. It is equivalent to the MQEnvironment variable MQ_PASSWORD .

If a security exit is not defined for this client, the value of password is transmitted to the server and is available to the server security exit when it is invoked.

The default value is "" (empty string).

port

public static int

The port to be used. This is the port on which WebSphere MQ listens for connection requests.

The default value is 1414.

properties

public static java.util.Hashtable

A Hashtable that defines the WebSphere MQ environment.

This Hashtable allows you to set environment properties as key/value pairs rather than as individual variables.

The properties can also be passed as a Hashtable in a parameter on the MQQueueManager constructor. Properties passed on the constructor take precedence over values set with this properties variable, but they are otherwise interchangeable. The order of precedence of finding properties is:

  1. properties parameter on MQQueueManager constructor
  2. MQEnvironment.properties
  3. Other MQEnvironment variables
  4. Constant default values

The property key names are:

receiveExit

public static com.ibm.mq.MQReceiveExit

The receive exit used when receiving messages from a queue manager. It allows you to examine, and possibly alter, data and is normally used in conjunction with a corresponding send exit at the queue manager.

If you want to provide your own receive exit, define a class that implements the MQReceiveExit interface, and assign receiveExit to an instance of that class.

If you set this field to null no receive exit is called.

securityExit

public static com.ibm.mq.MQSecurityExit

The security exit used when connecting to a queue manager. It allows you to customize the security flows that occur when an attempt is made to connect to a queue manager.

If you want to provide your own security exit, define a class that implements the MQSecurityExit interface and assign securityExit to an instance of that class.

If you set this field to null no security exit is called.

sendExit

public static com.ibm.mq.MQSendExit

The send exit used when sending messages to a queue manager. It allows you to examine, and possibly alter, data and is normally used in conjunction with a corresponding receive exit at the queue manager.

If you want to provide your own send exit, define a class that implements the MQSendExit interface, and assign sendExit to an instance of that class.

If you set this field to null no send exit is called.

sslCertStores

public static java.util.Collection

Collection of SSL CertStores. The collection of CertStores (J2SE v1.4 only) is used to enable WebSphere MQ Java clients to check certificates for revocation in a Certificate Revocation List (CRL).

sslCipherSuite

public static java.lang.String

The name of the Cipher Suite to be used by SSL. SSL is only valid for a client connection, and is triggered by setting sslCipherSuite . If sslCipherSuite is not set, all of the other values are irrelevant and a standard non-SSL connection is used to connect to the server.

sslFipsRequired

public static boolean

When this is set to true, the only Cipher Suites which can be used on an SSL connection from this client process are those which are FIPS-enabled. If this has been set to true and a customized sslSocketFactory has been specified the customized sslSocketFactory will not be used, as it cant be guaranteed that the sslSocketFactory is FIPS compliant.

sslPeerName

public static java.lang.String

The Distinguished Name (DN) of the queue manager to be used by SSL. The peer name is set to indicate that connections will only be allowed where the server is successfully authenticated as a specific DN.

sslResetCount

public static int

The total number of unencrypted bytes that are sent and received by the initiating channel MCA before the secret key is reset. The number of bytes includes control information sent by the message channel agent. A value of 0 disables secret key reset from occurring.

sslSocketFactory

public static java.lang.Object

The factory to use when connecting with SSL encryption. If sslCipherSuite is set, this variable can be used to customize all aspects of the SSL connection. For more information on constructing and customizing SSLSocketFactory instances, refer to your JSSE provider; for information regarding the use of this variable. If set to null (default) and SSL encryption is requested, the default SSLSocketFactory is used. This variable is ignored if sslCipherSuite is null.

userID

public static java.lang.String

The ID used to identify the WebSphere MQ client. It is equivalent to the WebSphere MQ environment variable MQ_USER_ID.

If no security exit is defined for this client, the value of userID is transmitted to the server and is available for use by the server security exit.

The default value is "" (empty string).

version_notice

public final static java.lang.String

The current version of the WebSphere MQ Java Classes.

Methods

addConnectionPoolToken

public static MQPoolToken addConnectionPoolToken();

Constructs an MQPoolToken and adds it to the set of tokens. The token is returned to the application to be passed later into removeConnectionPoolToken() method.

Returns

addConnectionPoolToken

public static void addConnectionPoolToken(MQPoolToken token);

Adds a given MQPoolToken to the connection pool. A default ConnectionManager can use this as a hint; typically, it is enabled only while there is at least one token in the connection pool.

Parameters

disableTracing

public static void disableTracing();

This method turns off the WebSphere MQ Client for Java trace facility.

enableTracing

public static void enableTracing(int level);

Turns on tracing at the specified trace level (traces to system.err). Levels are:

0
entry/exit.
1
as above plus error and exceptions.
2
as above plus some parameter and flow information.
3
as above plus data trace for headers flowing between client and queue manager.
4
as above plus full data trace of all data sent between client and queue manager.
5
as above plus Java VM method tracing.
Parameters

enableTracing

public static void enableTracing(int level, OutputStream stream);

This method turns on tracing at the specified trace level. See enableTracing(int) for details of levels.

Specifying a FileOutputStream means that in a WebSphere Application Server version 5 environment, the WebSphere MQ Base Java classes trace is not redirected to the WebSphere Application Server trace adapter which expects a JMS context.

If the trace string JMSApi=all=enabled is specified within the WebSphere Application Server version 5 environment at the same time as this is run, it takes priority and this tracing is disabled.

Parameters

getDefaultConnectionManager

public static ConnectionManager getDefaultConnectionManager();

Gets the default ConnectionManager.

Returns

getQueueManagerReference

public static MQQueueManager getQueueManagerReference(int scope);

Returns an MQQueueManager object reference if one is available within the specified scope. The scope must be one of MQC.ASSOCIATE_ALL or MQC.ASSOCIATE_THREAD , and a queue manager must already have been created with MQC.MQ_QMGR_ASSOCIATION_PROPERTY set to the scope requested.

If no queue manager has been created within the specified scope, or if MQC.ASSOCIATE_NONE is specified, this method will return null.

A call to this method is the same as calling MQEnvironment.getQueueManagerReference(int, Object) with a null Object.

Parameters
Returns

getQueueManagerReference

public static MQQueueManager getQueueManagerReference(int scope, 
                                                      Object context);

Returns an MQQueueManager object reference if one is available within the specified scope. The scope must be one of MQC.ASSOCIATE_ALL or MQC.ASSOCIATE_THREAD , and a queue manager must already have been created with MQC.MQ_QMGR_ASSOCIATION_PROPERTY set to the scope requested. The supplied Object gives information necessary to identify the MQQueueManager within the scope; for MQC.ASSOCIATE_ALL and MQC.ASSOCIATE_THREAD this Object must be a String containing the name of the queue manager

If no queue manager identified by the supplied Object has been created within the specified scope, or if MQC.ASSOCIATE_NONE is specified, this method will return null.

An MQQueueManager object returned by this method will refer to the same underlying HConn as the MQQueueManager created with MQC.MQ_QMGR_ASSOCIATION_PROPERTY set, and both will therefore share the same transaction context. If an attempt is made to create a second MQQueueManager object on the same context to a different queue manager, then a separate HConn will be made, and the first and second object will have independent transaction contexts. These contexts will extend to WebSphere MQ coordinated JDBC transactions by using MQQueueManager.getJDBCConnection(XADataSource) on the appropriate queue manager.

Parameters
Returns

getVersionNotice

public final static String getVersionNotice();

Gets the current version of the WebSphere MQ Java Classes.

Returns

removeConnectionPoolToken

public static void removeConnectionPoolToken(MQPoolToken token);

Removes a token from the connection pool.

Parameters

setDefaultConnectionManager

public static void setDefaultConnectionManager(ConnectionManager cxMan);

Sets the default ConnectionManager, and empties the set of MQPoolTokens. The default ConnectionManager is used no ConnectionManager is specified on the MQQueueManager constructor. This method requires a JVM at Java 2 V1.3 or later, with JAAS 1.0 or later installed.

Parameters

setDefaultConnectionManager

public static void setDefaultConnectionManager(MQConnectionManager mqCxMan);

Sets the supplied MQConnectionManager to be the default ConnectionManager. The default ConnectionManager is used when no ConnectionManager is specified on the MQQueueManager constructor. This method also empties the set of MQPoolTokens.

Parameters

traceSystemProperties

public static void traceSystemProperties();

Outputs the current System Properties to trace. Constructs a StringBuffer containing all the data and traces the entire contents in a single statement. This means that the results are all traced without the usual preceding timestamp and class hashcode. (although these will appear on the line above the properties block).