Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | Coding Messaging Client Applications | C# Messaging Clients | Sender-Receiver Application | Sending Messages in C#
 
Sending Messages in C#
C# messaging objects are coded like their JMS counterparts (for more information, see Coding Messaging Objects). Following is the C# code used in the sender application (SenderApplication.cs) to create the connection, session, and message producer objects, and send a message.
public void SendAMessage(String messageText)
{
IConnection conn = null;
 
try
{
conn = connectionFactory.CreateConnection();
ISession session = conn.CreateSession(false, AcknowledgeMode.Auto);
IMessageProducer sender = session.CreateProducer(destination);
 
ITextMessage msg = session.CreateTextMessage();
msg.Text = messageText;
 
Console.WriteLine("Sending message '" + messageText + "'");
sender.Send(msg);
...