how to add system.messaging c# code example
Example 1: how to add system.messaging c#
using System;
using System.Messaging;
namespace MyProject
{
public class MyNewQueue
{
public static void Main()
{
MyNewQueue myNewQueue = new MyNewQueue();
myNewQueue.SendPublic();
myNewQueue.SendPrivate();
myNewQueue.SendByLabel();
myNewQueue.SendByFormatName();
myNewQueue.MonitorComputerJournal();
myNewQueue.MonitorQueueJournal();
myNewQueue.MonitorDeadLetter();
myNewQueue.MonitorTransactionalDeadLetter();
return;
}
public void SendPublic()
{
MessageQueue myQueue = new MessageQueue(".\\myQueue");
myQueue.Send("Public queue by path name.");
return;
}
public void SendPrivate()
{
MessageQueue myQueue = new
MessageQueue(".\\Private$\\myQueue");
myQueue.Send("Private queue by path name.");
return;
}
public void SendByLabel()
{
MessageQueue myQueue = new MessageQueue("Label:TheLabel");
myQueue.Send("Queue by label.");
return;
}
public void SendByFormatName()
{
MessageQueue myQueue = new
MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4" +
"-935C-845C2AFF7112");
myQueue.Send("Queue by format name.");
return;
}
public void MonitorComputerJournal()
{
MessageQueue computerJournal = new
MessageQueue(".\\Journal$");
while(true)
{
Message journalMessage = computerJournal.Receive();
}
}
public void MonitorQueueJournal()
{
MessageQueue queueJournal = new
MessageQueue(".\\myQueue\\Journal$");
while(true)
{
Message journalMessage = queueJournal.Receive();
}
}
public void MonitorDeadLetter()
{
MessageQueue deadLetter = new
MessageQueue(".\\DeadLetter$");
while(true)
{
Message deadMessage = deadLetter.Receive();
}
}
public void MonitorTransactionalDeadLetter()
{
MessageQueue TxDeadLetter = new
MessageQueue(".\\XactDeadLetter$");
while(true)
{
Message txDeadLetter = TxDeadLetter.Receive();
}
}
}
}
Example 2: how to add system.messaging c#
[System.ComponentModel.TypeConverter(typeof(System.Messaging.Design.MessageQueueConverter))]
[System.Messaging.MessagingDescription("MessageQueueDesc")]
public class MessageQueue : System.ComponentModel.Component, System.Collections.IEnumerable