Broker 10.15 | 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;
try
{
conn = connectionFactory.CreateConnection();
ISession session = conn.CreateSession(false, AcknowledgeMode.Auto);
IMessageConsumer receiver = session.CreateConsumer(destination);
 
conn.Start();
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.