Controlling Event Subscriptions
The BrokerAdminClient.getClientGroupCanSubscribeList method lets you obtain all of the event types to which Broker clients belonging to a particular client group my subscribe or receive as a delivered event.
The following example illustrates how to get a client group's can-subscribe list:
. . .
int i;
String subscribe_events[];
BrokerAdminClient c;
try {
/* Create a Broker admin client */
c = new BrokerAdminClient(broker_host, broker_name, null,
client_group, "My Broker Monitor",null);
/* Get event types to which Broker clients in
* this client group may subscribe.
*/
subscribe_events = c.getClientGroupCanSubscribeList(“myGroup”);
for(i = 0; i < subscribe_events.length; i++) {
System.out.println(subscribe_events[i]);
}
} catch (BrokerException ex) {
System.out.println("Error while getting the can-subscribe list\n"+ex);
return;
}
. . .
Use the BrokerAdminClient.setClientGroupCanSubscribeList method to set the list of event types to which Broker clients belonging to a particular client group may subscribe.
The BrokerAdminClient.getClientGroupsWhichCanSubscribe method lets you obtain the names of all the client groups that may subscribe to a particular event type or receive a delivered event of that type.
The following example illustrates how to get client groups that can subscribe to an event type:
. . .
int i;
String groups[];
BrokerAdminClient c;
try {
/* Create a Broker admin client */
c = new BrokerAdminClient(broker_host, broker_name, null,
client_group, "My Broker Monitor",null);
/* Get a list of all client groups that may subscribe to
* particular event type.
*/
groups = c.getClientGroupsWhichCanPublish(“myEventType”);
for(i = 0; i < groups.length; i++) {
System.out.println(groups[i]);
}
} catch (BrokerException ex) {
System.out.println("Error while getting the client groups\n"+ex);
return;
}
. . .