Creating a connection definition

In order to create a connection definition will need to call the function:

mqeAdministrator_Connection_create(MQeAdministratorHndl, hAdmin,
                                   MQeExceptBlock* pExceptBlock,
                                   MQeStringHndl hConnectionName,
                                   MQeConnectionDefinitionParms* pParams);

The third parameter will define the name of the connection definition. As stated, this must be the name of the remote queue manager to which this connection definition holds the route.

The fourth parameter is a structure holding information that is required to setup the connection definition information. Either the hViaQMName field should be set or the hAdapterClass, phAdapterParams, destParmLen, hAdapterCommand and hChannelClass in order to create a connection definition. For instance, to create a connection definition, first create and set up an MQeConnectionDefinition parameter structure:

/* Create the structure and set it to the initial values */
MQeConnectionDefinitionParms parms = CONNDEF_INIT_VAL;

Create an MQeString to hold the name of the remote queue manager, this becomes the name of the connection definition:

rc = OSAMQESTRING_NEW(&error, "ServerQM", SB_STR, &hQueueMgrName);

Set the adapter and channel class names, these must be set to these names as these are the only classes currently supported:

parms.hAdapterClass = MQE_HTTP_ADAPTER;
parms.hChannelClass = MQE_CHANNEL_CLASS;

In order to set up an array we need to allocate some memory then setup the network information. This example shows using the loopback address with the listener expected to be on port 8080:

OSAMEMORY_ALLOC(&error, (MQEVOID**) &parms.phAdapterParms, 
                (sizeof(MQEHANDLE) * 2), "comms test");
rc = OSAMQESTRING_NEW(&error, "127.0.0.1", SB_STR, 
                      &parms.phAdapterParms[0]);
rc = OSAMQESTRING_NEW(&error, "8080", SB_STR, 
                      &parms.phAdapterParms[1]);

We now set the number of element in the array:

parms.destParmLen = 2;

And last of all set the flags to tell the receiving administration function what information it should look for in the structure:

parms.opFlags = CONNDEF_ADAPTER_CLASS_OP |
                CONNDEF_ADAPTER_PARMS_OP |
                CONNDEF_CHANNEL_CLASS_OP;

Now, having set everything up we can call the administration function in order to create our connection definition. Note, it is wise to check the return code in order to determine whether the call has been successful

rc = mqeAdministrator_Connection_create( hAdministrator, &error,
                                         hQueueMgrName, &parms);
if (MQERETURN_OK == rc) {
   fprintf(pOutput,
           "connection definition to ServerQM at 127.0.0.1:8081 successfully added\n");
   }

The above creates a direct connection definition, if we want to create a via connection definition we would need to set the parameter structure to the default values and the name of the remote queue manager as usual:

MQeConnectionDefinitionParms parms = CONNDEF_INIT_VAL;
rc = OSAMQESTRING_NEW(&error, "ServerQM", SB_STR, &hQueueMgrName);

We now need to set the name of the queue manager that will then route 
the messages on to the remote queue manager. 

rc = OSAMQESTRING_NEW(&error, 
                      "RoutingQM",
                      SB_STR, 
                      &parms.hViaQMName);

Now all that is left to do is correctly set the flags that tells the administration function what to look for in the structure:

parms.opFlags  = CONNDEF_VIAQM_OP;

We then call the function as with the direct connection definition:

rc = mqeAdministrator_Connection_create(hAdministrator, 
                                        &error,
                                        hQueueMgrName,
                                        &parms);

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.