Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | Coding Messaging Client Applications | C# Messaging Clients | Sender-Receiver Application | Receiving Messages in C#
Receiving Messages in C#
The following lines of C# code from ReceiverApplication.cs shows how to set up message reception (for more information, see Coding Messaging Objects).
public void ReceiveAMessage()
IConnection conn = null;
conn = connectionFactory.CreateConnection();
ISession session = conn.CreateSession(false, AcknowledgeMode.Auto);
IMessageConsumer receiver = session.CreateConsumer(destination);
IMessage msg = receiver.Receive();
You define the connection and session objects the same as for the message sender application. However, the message receiver defines a message consumer rather than a message producer. The message consumer is created calling createConsumer() on the session.