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 | Using publishRequestAndWait
 
Using publishRequestAndWait
BrokerClusterPublisher solution does not employ callback mechanism to achieve synchronous request-reply results. Rather it uses publish followed by getEvents approach to implement request-reply mechanism. In this way the automatic failover on the publish operation is available for request-reply model as well.
The following example illustrates how to use BrokerClusterPublisher.publishRequestAndWait for subscribers on the local Broker:
public static void main(String args[])
{
BrokerClusterPublisher bcp;
BrokerEvent e, events[];
int i;
. . .
/* create BrokerClusterPublisher */
. . .
/* create the request event to be sent and set the event fields */
. . .
/* publish the request and wait for a reply */
try {
events[] = bcp.localPublishRequestAndWait(e, 6000);
} catch (BrokerException ex) {
. . .
}
. . .
The following example illustrates how to use BrokerClusterPublisher().publishRequestAndWait for subscribers in a territory:
public static void main(String args[])
{
BrokerClusterPublisher bcp;
BrokerEvent e, events[];
int i;
. . .
/* create BrokerClusterPublisher */
. . .
/* create the request event to be sent and set the event fields */
. . .
/* publish the request and wait for a reply */
try {
events[] = bcp.publishRequestAndWait(e, 6000);
} catch (BrokerException ex) {
. . .
}
. . .