The following code fragment starts a client queue manager:
MQERETURN createQueueManager(MQeExceptBlock *pErrorBlock, MQeQueueManagerHndl *phQMgr, MQeFieldsHndl hInitFields, MQeStringHndl hQStore) { MQERETURN rc; MQeQueueManagerConfigureHndl hQMgrConfigure; /* Create instance of QueueManagerConfigure Class */ rc = mqeQueueManagerConfigure_new(pErrorBlock,&hQMgrConfigure, hInitFields,hQStore); if (MQERETURN_OK == rc) { /* define queue manager */ rc = mqeQueueManagerConfigure_defineQueueManager(hQMgrConfigure, pErrorBlock); if (MQERETURN_OK == rc) { /* define system default queues */ rc = mqeQueueManagerConfigure_defineDefaultSystemQueue(hQMgrConfigure, pErrorBlock, NULL); } /* close mqeQueueManagerConfigure */ (void)mqeQueueManagerConfigure_close(hQMgrConfigure, NULL); if (MQERETURN_OK == rc) { /* create queue manager */ rc = mqeQueueManager_new(pErrorBlock, phQMgr); if (MQERETURN_OK == rc) { rc = mqeQueueManager_activate(*phQMgr, pErrorBlock, hInitFields); } } /* free mqeQueueManagerConfigure */ (void)mqeQueueManagerConfigure_free(hQMgrConfigure, NULL); } return rc; }
/*-------------------------------------*/ /* 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 by using API call mqeQueueManager_getReference(queueManagerName)either from the static class variable MQeClient.queueManager or by using the static method MQeQueueManager.getReference(queueManagerName).
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. MQe and applications can use the aliases once they have been loaded.
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 */ }