When you have a message broker set up, it is important for administrators to always know the existing subscribers connected to the individual nodes in an MB cluster. It should also be possible to identify the respective nodes from which messages are consumed by each subscriber. These can be done using the Management Console of WSO2 MB.
Managing Queue subscriptions
You can view queue subscription details and close any subscription as required. See the following topics:
Viewing Queue subscriptions
Note that only authorized users will be allowed to view queue subscriptions using the Management Console as explained below. Find out about how permissions are enabled for a user from this link.
To view all the queue subscriptions, open the Management Console and click Queue Subscriptions in the Main tab. Whenever a queue subscription is created, the subscription page is updated. Subscription entries will exist as long as the subscriber connections are live.
The table below describes the information explained below:
|Exchange||The exchange to which the subscription is made. For queues, this is amq.direct.|
|Queue Name||Name of the queue subscription.|
|Destination||The JMS destination represented by the queue.|
|Durability||Determines whether or not the queue is durable.|
|Active||The status of the subscriber. If a connection to the server exists, the status will be 'Active'.|
|Owned Node||The node from which the subscription is made to the cluster. The IP address of the node is displayed.|
In addition to the above, the number of messages tentatively pending for a subscriber are shown. While the subscriber is receiving messages, you can click Refresh to see the message count eventually decrease to zero.
Closing Queue subscriptions
Note that only authorized users will be allowed to close a queue subscription using the Management Console as explained below. Find out about how permissions are enabled for a user from this link.
If there are erroneous queue subscribers connected to a particular queue, you (as the broker administrator) can remove such subscriptions by using the Close operation associated with the subscription. The following message will be prompted:
Managing Topic subscriptions
Topic subscription can be management in the same way as queue subscriptions.
When you subscribe to a topic in tenants, give the subscription name with the tenant domain. For example, if the subscription name is
subscription1 and the tenant domain is
bob.wso2.com, give the the subscription name as follows:
String subscriptionName ="bob.wso2.com/subscription1";
Viewing Topic subscriptions
Note that only authorized users will be allowed to view topic subscriptions using the Management Console as explained below. Find out about how permissions are enabled for a user from this link.
To view all the topic subscriptions, open the Management Console and click Topic Subscriptions in the Main tab. Topic subscriptions display similar information to queues. Some notable points are:
- Topic subscriptions display a queue name with subscription information. This is the internal queue name where messages belonging to the subscriber are accumulated.
- There are temporary topic subscriptions and durable topic subscriptions. Temporary topic subscriptions vanish as soon as the connection from the subscriber is closed, but durable topic subscribers are not removed from the broker. They will exist inside the broker cluster in the inActive mode.
- The message count is not displayed for temporary topic subscriptions, whereas it is displayed for durable topic subscribers.
- As inactive durable topic subscribers belong to the broker cluster, the Owned Node field is no longer applicable. If you make a subscription to the topic using the same subscription ID, that subscriber will be active once again.
- If you have the necessary permissions, you can unsubscribe the inactive durable topic subscribers. All messages belonging to that subscriber are then removed from the broker cluster. You cannot unsubscribe active durable topic subscriptions using the management console.
Closing topic subscriptions
If there are erroneous queue subscribers connect to a particular queue, you (as the broker administrator) can remove such subscriptions by using the Close operation associated with the subscription. Closing a subscription will affect topic subscriptions as explained below.
Note the following:
- The possibility to close a topic subscription is only available for the AMQP protocol. This function is not available for MQTT.
- Only authorized users will be allowed to close a topic subscription using the Management Console as explained below. Find out about how permissions are enabled for a user from this link.
- Non-durable topic subscriptions: The subscriber connection will be closed, and all associated resources are released.
- Durable topic subscriptions: The subscriber connection will be closed. However, the subscription will be listed as an 'inactive' subscription as shown below. All messages received by the topic subscriber is registered, cloned and persistently stored until the subscriber becomes active again.
Closing subscriptions in an MB cluster
In a clustered set up of WSO2 MB, subscribers are required to connect with an individual node in the cluster. Therefore, if you want to close a subscription, it is necessary to log in to the Management Console of the relevant MB node in the cluster. When you log in to the Management Console of one node in the cluster the Close operation will only be available for the subscriptions that are connected to the the MB instance to which you are logged in. For example, consider a broker cluster with 3 MB nodes (MB1, MB2 and MB3). You may have 3 subscribers connected to the 3 respective nodes: Sub1 connected to MB1, Sub2 connected to MB2 and Sub3 connected to MB3. In this scenario, you need to log in to the Management Console of MB1 in order to close Sub1. Therefore, this functionality of closing subscriptions is not symmetric across the cluster.