Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | Coding Messaging Client Applications | C# Messaging Clients | Application Code | Building the Query (Request) Message
Building the Query (Request) Message
In the C# API, as in JMS, the MessageListener delegate receives messages asynchronously. In this example, the delegate OnMessage is called whenever the server receives a customer request message. This implementation of ServerApplication.OnMessage() copies, from the request message, the customer information needed to make the database query. It then issues the query and builds the reply message, calling ConstructReplyMessage() to map data from the customer record to the reply message fields. The following code from OnMessage() shows these steps.
try {
IMessage reply;
String command = message.GetStringProperty
Console.WriteLine("OnMessage::Received a command " + command);
if (command.Equals(ApplicationConstants.CUSTOMER_QUERY_COMMAND,
StringComparison.InvariantCultureIgnoreCase)) {
try {
if (message is IMapMessage) {
IMapMessage queryMsg = (IMapMessage) message;
String firstName = queryMsg.GetString
String lastName = queryMsg.GetString
String location = queryMsg.GetStringProperty
CustomerDB.CustomerRecord customer =
customerDb.lookup(firstName, lastName, location);
Console.WriteLine("OnMessage::QueryCommand with
FirstName=" + firstName + ";LastName=" +
lastName + ";Location=" + location);
reply = ConstructReplyMsg(customer);
} ...