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 an Event
 
Publishing an Event
After initializing the necessary event fields, your application can publish an event by calling the BrokerClusterPublisher.publish method. The following example contains an excerpt from a sample application that shows the use of the BrokerClusterPublisher.publish method. This method accepts a BrokerEvent.
BrokerClusterPublisher can publish an event that is targeted for subscribers on the Broker on which the event is published or to all the subscribers on any Broker in the territory.
The following example illustrates how to publish a single event to territory subscribers:
. . .
BrokerClusterPublisher bcp;
BrokerEvent e;
. . .
try {
bcp.publish(e);
} catch (BrokerException ex) {
System.out.println("Error on publish\n"+ex);
return;
}
. . .
The following example illustrates how to publish a single event to subscribers on the local Broker only:
. . .
BrokerClusterPublisher bcp;
BrokerEvent e;
. . .
try {
bcp.localPublish(e);
} catch (BrokerException ex) {
System.out.println("Error on publish\n"+ex);
return;
}
. . .