Synchronous and asynchronous

The difference between the two types of remote queue definitions is described in the WebSphere MQ Everyplace Application Programming Guide. To summarize:

Synchronous
Synchronous remote queues are queues that can only be accessed when connected to a network that has a communications path to the owning queue manager. If the network is not established then the operations such as put, get, and browse cause an exception to be raised. The owning queue controls the access permissions and security requirements needed to access the queue. It is the responsibility of the application to handle any errors or retries when sending or receiving messages as, in this case, WebSphere MQ Everyplace is no longer responsible for once-only assured delivery.

Asynchronous
Asynchronous remote queues are queues that move messages to remote queues, but cannot remotely retrieve messages. When messages are put to the remote queue, the messages are temporarily stored locally. When connected to a network, this triggers transmission, allowing an attempt to move the messages to the target queue. Message delivery is once-only assured delivery. This allows applications to operate on the queue when the device is offline. Consequently, asynchronous queues require a message store so that messages are temporarily stored at the sending queue manager when awaiting transmission.
Note:
In the Java codebase, the mode of an instance of the MQeRemoteQueue class is set to Queue_Synchronous or Queue_Asynchronous to indicate whether the queue is synchronous or asynchronous. In the native codebase, two distinct sets of APIs are used to create and administer synchronous and asynchronous remote queues.

Figure 31 shows an example of a remote queue set up for synchronous operation and a remote queue setup for asynchronous operation.

Figure 31. Remote queue

top

In both the synchronous and asynchronous examples queue manager qm2 has a local queue invQ.

In the synchronous example, queue manager qm1 has a remote queue definition of queue invQ. invQ resides on queue manager qm2. The mode of operation is set to synchronous.

An application using queue manager qm1 and putting messages to queue qm2.invQ establishes a network connection to queue manager qm2, if it does not already exist, and the message is immediately put on the real queue. If the network connection cannot be established then the application receives an exception that it must handle.

In the asynchronous example, queue manager qm1 has a remote queue definition of queue invQ. invQ resides on queue manager qm2. The mode of operation is set to asynchronous.

An application using queue manager qm1 and putting messages to queue qm2.invQ stores messages temporarily on the remote queue on qm1. When the transmission rules allow, the message is moved to the real queue on queue manager qm2. The message remains on the remote queue until the transmission is successful.

Setting the operation mode

To set a queue for synchronous operation, set the Queue_Mode field to Queue_Synchronous.

Asynchronous queues require a message store to temporarily store messages. Definition of this message store is the same as for local queues.

To set a queue for asynchronous operation, set the Queue_Mode field to Queue_Asynchronous.

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. All Rights Reserved