CompareConnection interface method

The CompareConnection method is called by the Resource Manager to determine whether a connection can be reused.

It is called in two cases:
  • To determine whether multiple adapter references within the same map can share a connection.
  • To determine whether a connection that is currently inactive can be used by a map.
This method can be logically equivalent to CompareWatches.
MPIRC CompareConnection (HMPIADAPT  hAdapter, HMPICONNECT  hConnection,
												MPICOMP *peComp)

Inputs

hAdapter
Adapter handle for the potentially new connection.
hConnection
Connection handle for the existing connection.

Outputs

peComp
MPI_CMP_EQUAL
Connection corresponds.
MPI_CMP_DIFFER
Connection does not correspond.
MPI_CMP_LESS
Connection is less than adapter.
MPI_CMP_GREATER
Connection is greater than adapter.

Returns

Success status

The adapter consults the properties for the adapter object and the connection object and determines whether the properties correspond such that the connection might be reused for the adapter object. The MPIP_CONNECTION_INUSE property determines whether the connection object is currently being used in a map. If this property is FALSE, the connection is currently idle.

Besides adapter-specific properties, other properties might be important in determining whether a connection can be reused. For example, MPIP_ADAPTER_ON_FAILURE determines whether to rollback or commit at the end of the transaction. If this is set to MPI_ACTION_COMMIT for one adapter object, but MPI_ACTION_ROLLBACK for another, it is most unlikely that the connection should be shared if the connection is active.

If the sense of ordering in comparisons can be made, the number of comparisons can be reduced because every existing connection does not have to be compared when searching for a valid connection to use.

In the following code example, a resource is identified by QueueManager.
mpiPropertyGetText(hAdapter, MYPROP_Q_MGR, 0, &pAdaptQMgr, &iLen);
mpiPropertyGetText(hConnection, MYPROP_Q_MGR, 0, &pConnQMgr, &iLen);
rc = strcmp(pAdaptQMgr, pConnQMgr);
if (rc == 0)
return MPI_CMP_EQUAL;
else if (rc < 0)
return MPI_CMP_LESS;
else 
return MPI_CMP_GREATER;