Client queue managers

A client typically runs on a device platform, and provides a queue manager that can be used by applications on the device. It can open many connections to other queue managers.

A server usually runs for long periods of time, but clients are started and stopped on demand by the application that use them. If multiple applications want to share a client , the applications must coordinate the starting and stopping of the client.

Starting a client queue manager

Starting a client queue manager involves:

  1. Ensuring that there is no client already running. (Only one client is allowed per Java Virtual Machine.)
  2. Adding any aliases to the system
  3. Enabling trace if required
  4. Starting the queue manager

The following code fragment starts a client queue manager:

/*-------------------------------------*/
/* Init - first stage setup       		  */
/*-------------------------------------*/
public void init( MQeFields parms ) throws Exception
{
  if ( queueManager != null )                
/* One queue manager at a time   */
  {
    throw new Exception( "Client already running" );
  }
  sections = parms;                          
/* Remember startup parms        */
  MQeQueueManagerUtils.processAlias( sections ); 
/* set any alias names       */
 
// Uncomment the following line to start trace 
		before the queue manager is started
//  MQeQueueManagerUtils.traceOn("MQeClient Trace", null); 
/* Turn trace on   */
 
  /* Display the startup parameters */
  System.out.println( sections.dumpToString("#1\t=\t#2\r\n"));
 
  /* Start the queue manage  */
  queueManager = MQeQueueManagerUtils.processQueueManager( sections, null);
}
 

Once you have started the client, you can obtain a reference to the queue manager object either from the static class variable MQeClient.queueManager or by using the static method MQeQueueManager.getReference(queueManagerName).

The following code fragment loads aliases into the system:

public static void processAlias( MQeFields sections ) throws Exception
{
  if ( sections.contains( Section_Alias ) )   
/* section present ?            */
  {                                           
/* ... yes                      */
    MQeFields section = sections.getFields( Section_Alias );
    Enumeration keys  = section.fields( );    
/* get all the keywords         */
    while ( keys.hasMoreElements() )          
/* as long as there are keywords*/
    {                                         
      String    key   = (String) keys.nextElement();     
/* get the Keyword   */
      MQe.alias( key, section.getAscii( key ).trim( ) ); 
/* add               */
    }                                       
  }
}      
 

Use the processAlias method to add each alias to the system. WebSphere MQ Everyplace and applications can use the aliases once they have been loaded.

Starting a queue manager involves:

  1. Instantiating a queue manager. The name of the queue manager class to load is specified in the alias QueueManager. Use the WebSphere MQ Everyplace class loader to load the class and call the null constructor.
  2. Activate the queue manager. Use the activate method, passing the MQeFields object representation of the ini file. The queue manager only makes use of the [QueueManager] and [Registry] sections from the startup parameters.

The following code fragment starts a queue manager:

public static MQeQueueManager processQueueManager( MQeFields sections,
		 Hashtable ght ) throws Exception
{                                             
/*                              */
  MQeQueueManager queueManager = null;        
/* work variable                */
  if ( sections.contains( Section_QueueManager) )     
/* section present ?    */
  {                                           
/* ... yes                      */
   queueManager = (MQeQueueManager) MQe.loader.loadObject(Section_QueueManager);
    if ( queueManager != null )               
/* is there a Q manager ?       */
    {
      queueManager.setGlobalHashTable( ght );
      queueManager.activate( sections );      
/* ... yes, activate            */
    }
  }                                           
  return( queueManager );                     
/* return the alloated mgr      */
}      
 

Example MQePrivateClient

MQePrivateClient is an extension of MQeClient with the addition that it configures the queue manager and registry to allow for secure queues. For a secure client, the [Registry] section of the startup parameters is extended as follows:

(ascii)LocalRegType=PrivateRegistry
 
   Location of the registry
 
(ascii)DirName=.\ExampleQM\PrivateRegistry
   Adapter on which registry sits
(ascii)Adapter=RegistryAdapter
Network address of certificate authority
 
(ascii)CAIPAddrPort=9.20.7.219:8082
 

Refer to Security for more details on secure queues and MQePrivateClient.

For MQePrivateClient and MQePrivateServer to work, the startup parameters must not contain CertReqPIN, KeyRingPassword and CAIPAddrPort.



© IBM Corporation 2002. All Rights Reserved