Creating a remote queue

The following code fragment shows how to setup an administration message to create a remote queue.

/**
 * Create a remote queue
 */
protected void createQueue(MQeQueueManager localQM,
                          String     targetQMgr,
                          String     qMgrName,       
                         	String    	queueName,
 	     							String	  	description,
                         	String		queueStore,
 	     							byte      queueMode
 	) throws Exception
{
  /*
   * Create an empty queue admin 
		message and parameters field
   */
  MQeRemoteQueueAdminMsg msg = new MQeRemoteQueueAdminMsg();
  MQeFields parms = new MQeFields();
 
  /*
   * Prime message with who to reply 
		to and a unique identifier
   */
  MQeFields msgTest = primeAdminMsg( msg );
 
  /*
   * Set name of queue to manage
   */
  msg.setName( qMgrName, queueName );
 
  /*
   * Add any characteristics of queue here, otherwise
   * charateristics will be left to default values.
   /
  if ( description != null )	// set the description ?
    parms.putUnicode( MQeQueueAdminMsg.Queue_Description, 
                      description);
 
  // set the queue access mode if mode is valid
  if ( queueStore != MQeQueueAdminMsg.Queue_Asynchronous &&
       	queueStore != MQeQueueAdminMsg.Queue_Synchronous )
    throw new Exception ("Invalid queue store");
 
    parms.putByte( MQeQueueAdminMsg.Queue_Mode, 
                queueMode);
 
  if ( queueStore != null ) 	// Set the queue store ?
    // If queue store includes directory and file info then it
    // must be set to the correct style for the system that the
    // queue will reside on e.g \ or /
    parms.putAscii( MQeQueueAdminMsg.Queue_FileDesc, 
                    queueStore );
  /* 
   * Other queue characteristics like queue depth, message expiry
   * can be set here ...
   */
 
  /*
   * Set the admin action to create a new queue
   */
  msg.create( parms );
 
  /*
   *  Put the admin message to the admin 
		queue (not assured delivery)
   *  on the target queue manager
   */
  localQM.putMessage( targetQMgr, 
                      MQe.Admin_Queue_Name, 
                      msg, 
                      null, 
                      0);
}
 

For synchronous operation, the queue characteristics for inclusion in the remote queue definition can be obtained using queue discovery.



© IBM Corporation 2002, 2003. All Rights Reserved