MQUnsubscribe() function

The MQUnsubscribe() function is used to unregister interest in WMQ messages published on one or more topics.

Syntax


1  MQUNSUBSCRIBE (?  subscriber_name ,?  policy_name ,  topic )
subscriber_name
Optional parameter. Refers to the value in the pubsubname column of the "informix".mqiservice table. If subscriber_name is not specified, IDS.DEFAULT.SUBSCRIBER is used as the subscriber. The maximum size of subscriber_name is 48 bytes.
policy_name
Optional parameter. Refers to the value in the policyname column of the "informix".mqipolicy table. If policy_name is not specified, IDS.DEFAULT.PUB.SUB.POLICY is used as the policy. The maximum size of policy_name is 48 bytes.
topic
Required parameter. A string containing the topic for the message publication. The maximum size of a topic is 40 bytes. Multiple topics can be specified in one string (up to 40 characters long). Each topic must be separated by a colon. For example, "t1:t2:the third topic" indicates that the message is associated with all three topics: t1, t2, and the third topic. If no topic is specified, none are associated with the message.

Usage

The MQUnsubscribe() function is used to unregister interest in WMQ messages subscription on a specified topic. The subscriber_name specifies a logical destination for messages that match the specified topic.

This function requires the installation of the WMQ Publish/Subscribe Component of WMQ and that the Message Broker must be running.

The following table describes how the arguments for the MQUnsubscribe() function are interpreted.
Table 1. MQUnsubscribe() argument interpretation
Usage Argument interpretation
MQUnsubscribe(arg1) arg1 = topic
MQUnsubscribe(arg1, arg2) arg1 = service_name

arg2 = topic

MQUnsubscribe(arg1, arg2, arg3) arg1 = service_name

arg2 = policy_name

arg3 = topic

Return codes

1
The operation was successful.
Error
The operation was unsuccessful.

Examples

Example 1
begin;
EXECUTE FUNCTION MQUnsubscribe('Weather');
commit;
This example demonstrates unsubscribing an interest in messages containing the topic "Weather" with the following parameters:
  • subscriber_name: default subscriber
  • policy_name: default policy
  • topic: "Weather"
Example 2
begin;
EXECUTE FUNCTION MQUnsubscribe('PORTFOLIO-UPDATES','BASIC-POLICY',
      'Stocks:Bonds');
commit;
This example demonstrates unsubscribing an interest in messages containing the topics "Stocks" and "Bonds" with the following parameters:
  • subscriber_name: "PORTFOLIO-UPDATES"
  • policy_name: "BASIC-POLICY"
  • topic: "Stocks", "Bonds"