Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client C API Programmer's Guide | Using Request-Reply | The Requestor
The Requestor
Using the Get-event Approach
Other Reply Event Functions
Callback Functions with Tags
Using awPublishRequestAndWait
Delivering Request Events
You have several processing models to choose from when designing a requestor application. These design alternatives include:
*Use awPublishEvent to send the request event, use awGetEvent to receive possible reply events, and check each event received for a matching tag.
*Create a callback function for the response event and register it with awRegisterCallbackWithTag, specifying the tag you will use. Use awPublishEvent to send the request event and then use one of the webMethods Broker dispatching functions to dispatch received events.
*Use awPublishRequestAndWait to send the request event and wait until a reply event is received.
The following example shows the code that implements the preliminary processing for requestor applications. It follows these steps:
1. Create a BrokerClient.
2. Check for publication permission for the request event type.
3. Check for subscription permission for the reply event type. This is done even though the reply event will be delivered because it indicates whether or not the requestor's client group will allow it to receive the reply event type.
4. Create a request BrokerEvent.
5. Create a tag for the request event using the awMakeTag function.
6. Set the request event's tag field using the awSetEventTag function.
. . .
BrokerClient c;
BrokerEvent e;
BrokerBoolean b;
int request_tag;
. . .
/* Create a client */
err = awNewBrokerClient(broker_host, broker_name, NULL
"default", "Reqestor", NULL, &c);
/* Check for errors */
. . .
/* Check if can publish */
err = awCanPublish(c, "Sample::Request", &b);
/* Check for errors */
. . .
/* Check if can subscribe */
err = awCanSubscribe(c, "Sample::Reply", &b);
/* Check for errors */
. . .
/* Create the request event */
err = awNewBrokerEvent(c, "Sample::Request", &e);
/* Check for errors */
. . .
/* Create tag and set tag field */
request_tag = awMakeTag(c);
err = awSetEventTag(e, request_tag);
/* Check for errors */
. . .