Broker 10.15 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Using Request-Reply | The Server | Checking Subscription and Publishing Permissions
 
Checking Subscription and Publishing Permissions
The Server shown in the following example checks to see if it has permission to subscribe to the request event and to deliver the appropriate reply event. The BrokerClient.canPublish method is used to determine whether the Broker client has the necessary permissions to deliver the various reply events. In this example, the application expects that it might have to deliver the event types shown in the following table:
Event Type
Description
Adapter::error
Used to indicate that an exception occurred in the processing of the event.
Adapter::ack
Used if the infoset for Sample::Request specifies that a simple success or failure indication is all that is expected.
Sample::Reply
Used if the infoset for Sample::Request defines a specific event type as a response.
boolean permission;
BrokerClient c;
. . .
/* Create a Broker client */
. . .
/* Check if can publish reply */
try {
permission = c.canPublish("Sample::Reply");
} catch (BrokerException ex) {
. . .
}
if(!permission) {
System.out.println("Permission to publish Sample::Reply denied.\n");
return;
}
/* Check if can publish error reply */
try {
permission = c.canPublish("Adapter::error");
} catch (BrokerException ex) {
. . .
}
if(!permission) {
System.out.println("Permission to publish Adapter::error denied.\n");
return;
}
/* Check if can publish acknowledgement */
try {
permission = c.canPublish("Adapter::ack");
} catch (BrokerException ex) {
. . .
}
if(!permission) {
System.out.println("Permission to publish Adapter::ack denied.\n");
return;
}
/* Check if can subscribe to the request event */
try {
permission = c.canSubscribe("Sample::Request");
} catch (BrokerException ex) {
. . .
}
if(!permission) {
System.out.println("Cannot subscribe to Sample::Request denied.\n");
return;
}

/* Subscribe to the request event */
try {
c.newsubscription("Sample::request", null);
} catch (BrokerException ex) {
. . .
}
. . .