IBM MQSeries JMS

The IBM MQSeries range of products provides services that enable applications to communicate with each other using messages and queues. IBM provides support for developing MQSeries applications in Java, through a number of Java-based APIs, which are downloaded separately. A 60-day trial version of the software can be downloaded from http://www-4.ibm.com/software/ts/mqseries/downloads/, while the Java APIs can be found at http://www-4.ibm.com/software/ts/mqseries/api/mqjava.html.

MQSeries JMS Features

MQSeries JMS supports both the PTP and Pub/Sub messaging models. However the latter model requires Service Pac MA0C to be installed on top of the main application:

  • MQSeries Java enables Java applets, applications, and servlets to issue calls and queries to MQSeries, giving access to mainframe and legacy applications without necessarily having any other MQSeries code on the client machine.

  • The MQSeries JMS classes add the following over the base MQSeries functions:

    • Asynchronous message delivery

    • Message selectors

    • Support for Pub/Sub messaging

    • Structured message classes

  • MQSeries initializes authorization checks that are carried out on each resource, using the tables that are set up and maintained by the MQSeries administrator.

  • Data integrity is provided via units of work. The synchronization of the start and end of units of work is fully supported as an option on each message get/set method call, allowing the results of the unit of work to be committed or rolled back.

  • Recovery support is provided by logging all persistent MQSeries updates

MQSeries Binaries

MQSeries comes with binaries for configuring Administered objects and assisting in the running of programs. Once MQSeries has been installed, it will run in the background until told to stop. On Windows platforms the server's status can be checked by examining the MQSeries icon in the system tray. A green arrow signifies that the server is up and running, while a red arrow signifies that it has been stopped. The server can be configured, started, and stopped by right-clicking on this icon.

runjms

MQJMS includes a utility file, runjms (runjms.bat on Windows NT) to help you to run JMS programs. The Java properties needed for trace and logging are passed in as arguments. The directory names used in the file are suggested defaults that may be altered to suit your particular installation:

     java -DMQJMS_LOG_DIR="%MQ_JAVA_INSTALL_PATH%"\log -     DMQJMS_TRACE_DIR=" %MQ_JAVA_INSTALL_PATH% " \ trace-     DMQJMS_TRACE_LEVEL="%MQJMS_TRACE_LEVEL%" %1 %2 %3 %4 %5 %6 %7 %8 %9 

JMSAdmin

To run the MQJMS admin tool, execute the JMSAdmin utility file (JMSAdmin.bat on Windows platforms) found in the installation directory.

This admin tool can be used to configure Administered objects or run a batch process. The configuration mode provides a command line where administration commands can be entered. The command to start the tool in batch mode must include the name of a file that contains an administration command script.

In order for the admin tool to function correctly, the JMSAdmin.config file must be set up correctly. This file is found in the same directory as the JMSAdmin utility file. The following lines must be changed to suit your system's LDAP or file system setup. The # character denotes a comment. If you wish to swap between a file system and LDAP, comment out the file system line and remove the comment from the LDAP line:

     #PROVIDER_URL=ldap://localhost:389     PROVIDER_URL=file://C:/temp     #INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory     INITIAL_CONTEXT_FACTORY=com.sun.jndi. fscontext.RefFSContextFactory 

JMSAdmin.config contains the default settings for the admin console, but you can provide an alternative configuration file at the command prompt by invoking the optional -cfg parameter, followed by the alternative filename.

Once the admin tool has been started, Administered objects can be configured using a set of configuration commands of the form VERB [param]*. A full listing of these commands can be found in the MQSeries JMS documentation. Below is an example of a queue connection factory being configured:

click to expand

Running the Portable JMS Client

The topic and topic connection factory are stored in the WinNT file system context for MQSeries JMS (we could also use LDAP, see JMSAdmin earlier in this section).

Configuring the Administered Objects

We will be storing the Administered objects under the directory C:\temp in the WinNT file system context for the MQSeries JMS. The implementations for the interfaces for topic and topic connection factory can be created and stored in a JNDI namespace using the JMSAdmin tool explained earlier. Make sure the JMSAdmin.config file contains the following uncommented lines, while all references to LDAP should be commented out:

     PROVIDER_URL=file://C:/temp     INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory 

Run the following commands to store the topic myTopic and the topic connection factory TCFactory in the WinNT file system context. The final command verifies that the process was successful by displaying the contents of the current context:

click to expand

Running the Client

In MQSeries, queues are managed by a component called a queue manager. The queue manager provides messaging services for applications and ensures that messages are put on the correct queue or that they are routed to another queue manager. Before applications can send any messages, you must create a queue manager.

The screenshot below shows the process involved in creating a queue manager. Make sure that the MQSeries server is up and running as described above. First check to see if a queue manager is already up and running. The default name for a queue manager is QM_<host_name>, but this can be changed at time of installation. If there is no queue manager running, start one up. Finally a number of system queues must be created using the MQJMS_PSQ.mqsc script file:

click to expand

The following files must be specified in the classpath:

  • com.ibm.mq.jar — This JAR file contains Java implementations of the MQSeries connection options

  • com. ibm.mqjms.jar — This JAR file contains MQSeries'JMS implementation classes

The following command-line arguments should be passed to the program for running the client:

  • com.sun.jndi.fscontext.RefFSContextFactory — This is the initial context factory for the JNDI file system context

  • file:C:/temp: This is the JNDI service provider URL

The screenshot below shows the JMS client running against MQSeries JMS:

click to expand



Professional JMS
Professional JMS
ISBN: 1861004931
EAN: 2147483647
Year: 2000
Pages: 154

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net