Home

 

Publisher and subscriber identity

 

+

Search Tips   |   Advanced Search

 

A publisher's or subscriber's identity consists of...

Alternatively, the subscriber's identity can consist of a subscription name.

The correlation identifier can be used to distinguish between different publishers or subscribers using the same queue. If different subscribers are using the same queue, all publications sent by the broker to a subscriber specify the correlation identifier in the CorrelId field of the message descriptor (MQMD).

For responses, MQRO_xx_CORREL_ID report options determine the correlation identifier used. Applications using a correlation identifier for identification typically specify the CorrelId and the MQRO_PASS_CORREL_ID option.

The recipient can then use MQGET with the CorrelId to retrieve the messages.

This allows several applications to share a queue (this might be desirable if there are many clients). It also allows one application to distinguish between publications arising from different subscriptions. An example of this is in the sample program described on page Sample application. When the results service restarts, it subscribes to the topic...

Sport/Soccer/State/LatestScore/*

...with the 'Publish on Request Only' option. It uses a different CorrelId from that used to subscribe to the publicatins...

Sport/Soccer/Event/*

This allows it to retrieve from the same queue all the retained 'LatestScore' publications before it starts processing the event publications again.

An identity that includes the correlation identifier in the message descriptor is established by including MQPS_CORREL_ID_AS_IDENTITY in the RegistrationOptions parameter of the Register Publisher or Register Subscriber message (or of the Publish message for implicit registration). The correlation identifier to be used as part of the identity must not be zero.

If MQPS_CORREL_ID_AS_IDENTITY is not set, the identity does not include the correlation identifier and the broker uses a correlation identifier of its own choosing when sending messages to that publisher or subscriber. When a broker selects the correlation identifier itself, this does not conflict with other message identifiers or correlation identifiers generated by queue managers.

A single publisher or subscriber queue can therefore support multiple identities, each with a specific correlation identifier value, plus one further identity for which the correlation identifier is not specified (MQPS_CORREL_ID_AS_IDENTITY was not set for registration). Each identity is treated by the broker as being independent of the others. (Usually, however, a queue has either a number of identities each with its own specific correlation identifier, or only one identity with no specific correlation identifier).

MQPS_CORREL_ID_AS_IDENTITY should be set by a publisher whose identity includes a correlation identifier when sending a Publish message to the broker, so that the broker can identify the publisher using the CorrelId field in the MQMD. If such a message is received by the broker when there is no registration in effect for the publisher's queue and the correlation identifier specified, an implicit registration is performed (unless MQPS_NO_REGISTRATION is specified).

When a Publish message is sent by a broker to a subscriber whose identity includes a correlation identifier, the CorrelId field in the MQMD is set to the required correlation identifier. The correlation identifier sent to the subscriber depends only upon what the subscriber set when it registered. The correlation identifier used by the publisher is independent of the correlation identifier sent to the subscriber.

MQPS_CORREL_ID_AS_IDENTITY is valid for the Deregister Publisher and Deregister Subscriber message, to delete a registration for an identity that includes a correlation identifier.

The value used for a correlation identifier that is part of a publisher's or subscriber's identity needs to be unique only between the other users of the same queue. The MQPMO_NEW_CORREL_ID option can be used to cause the queue manager to generate a unique value.

 

Home