Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Load Balancing and Failover for Publish Operations | Publishing and Delivering Events | Publishing Events
 
Publishing Events
When your client application publishes an event, the Broker places it in the event queue of each BrokerClient that has subscribed to that event type. In order for your application to be able to publish an event, it must first create a BrokerClusterPublisher. Your application can then use the BrokerClusterPublisher to create an event, as described in the previous example. After setting the event fields, your application is ready to publish the event.
The client group to which the BrokerClusterPublisher belongs defines the event types the BrokerClusterPublisher can publish. See Client Groups for more information.
The following example contains an excerpt from a sample application that shows the use of the BrokerClusterPublish.canPublish method to check for event publication permission. This method requires an event type name.
. . .
BrokerClusterPublisher bcp;
boolean can_publish;
. . .
/* Check publish permission */
try {
can_publish = bcp.canPublish("Sample::SimpleEvent");
} catch (BrokerException ex) {
System.out.println("Error on check for can publish\n"+ex);
return;
}
if (can_publish == false) {
System.out.println("Cannot publish event");
System.out.println("Sample::SimpleEvent.");
System.out.println("Make sure it is loaded in the broker and");
System.out.println("permission is given to publish it in the");
System.out.println(client_group + " client group.");
return;
}
. . .
You can also use the BrokerClusterPublisher.getCanPublishNames method to obtain the names of all the event types which a BrokerClusterPublisher can publish.