Setting up the IBM MQ environment for IBM MQ classes for Java
For an application to connect to a queue manager in client mode, the application must specify the channel name, host name, and port number.
You can specify the channel name, host name, and port number in one of two ways: either as fields in the MQEnvironment class or as properties of the MQQueueManager object.
MQEnvironment.hostname = "host.domain.com";
MQEnvironment.channel = "java.client.channel";
"java.client.channel/TCP/host.domain.com".
MQEnvironment.port = nnnn;
where nnnn is the required port number
If you pass properties to a queue manager object at its creation, they apply only to that queue manager. Create entries in a Hashtable object with keys of hostname, channel, and, optionally, port, and with appropriate values. To use the default port, 1414, you can omit the port entry. Create the MQQueueManager object by using a constructor that accepts the properties hash table.
Identifying a connection to the queue manager by setting an application name
An application can set a name that identifies its connection to the queue manager. This application name is shown by the DISPLAY CONN MQSC/PCF command (where the field is called APPLTAG ) or in the IBM MQ Explorer Application Connections display (where the field is called App name ).
Application names are limited to 28 characters and longer names are truncated to fit. If an application name is not specified, a default is provided. The default name is based on the invoking (main) class, but if this information is not available, the text WebSphere MQ Client for Java is used.
If the name of the invoking class is used, it is adjusted to fit by removing leading package names, if necessary. For example, if the invoking class is com.example.MainApp
, the full name is used, but if the invoking class is com.example.dictionaryAndThesaurus.multilingual.mainApp
, the name multilingual.mainApp
is used, because it is the longest combination of class name and rightmost package name that fits into the available length.
If the class name itself is more than 28 characters long, it is truncated to fit. For example, com.example.mainApplicationForSecondTestCase
becomes mainApplicationForSecondTest
.
MQEnvironment.properties.put(MQConstants.APPNAME_PROPERTY, "my_application_name");
To set an application name in the properties hash table that is passed to the MQQueueManager constructor, add the name to the properties hash table with a key of MQConstants.APPNAME_PROPERTY.
Overriding properties specified in an IBM MQ client configuration file
An IBM MQ client configuration file can also specify properties that are used to configure IBM MQ classes for Java. However, properties specified in an IBM MQ MQI client configuration file apply only when an application connects to a queue manager in client mode.
- Set a Java system property for the configuration property.
- Set the property in the MQEnvironment.properties map.
- On Java5 and later releases, set a system environment variable.
Stanza | Attribute |
---|---|
ClientExitPath stanza of the client configuration file | ExitsDefaultPath |
ClientExitPath stanza of the client configuration file | ExitsDefaultPath64 |
ClientExitPath stanza of the client configuration file | JavaExitsClasspath |
MessageBuffer stanza of the client configuration file | MaximumSize |
MessageBuffer stanza of the client configuration file | PurgeTime |
MessageBuffer stanza of the client configuration file | UpdatePercentage |
TCP stanza of the client configuration file | ClntRcvBufSize |
TCP stanza of the client configuration file | ClntSndBufSize |
TCP stanza of the client configuration file | Connect_Timeout |
TCP stanza of the client configuration file | KeepAlive |