[보내기]
string QueryName = "FormatName:Direct=TCP:10.115.6.222\\MyPopUpQueue";
QueryName = ".\\Private$\\MyPopUpQueue";
MessageQueue messageQueue = null;
if (MessageQueue.Exists(QueryName))
{
messageQueue = new MessageQueue(QueryName);
messageQueue.Label = "Testing Queue1";
}
else
{
// Create the Queue
MessageQueue.Create(QueryName);
messageQueue = new MessageQueue(QueryName);
messageQueue.Label = "Newly Created Queue1";
}
System.Messaging.Message message = new System.Messaging.Message("MyPopUpQueue");
message.Priority = MessagePriority.Low;
//message.DefaultPropertiesToSend.Recoverable = true;
messageQueue.Send(textBox1.Text, "Message 1");
[받기]
string QueryName = "FormatName:Direct=TCP:10.115.6.222\\private$\\MyPopUpQueue";
//MessageQueue messageQueue = new MessageQueue(@".\Private$\MyPopUpQueue");
MessageQueue messageQueue = new MessageQueue(QueryName);
messageQueue.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });
// iterating the queue contents
//System.Messaging.Message mes = messageQueue.Receive(new TimeSpan(0, 0, 3));
//mes.Formatter = new XmlMessageFormatter(
// new String[] { "System.String,mscorlib" });
//string m = mes.Body.ToString();
foreach (System.Messaging.Message msg in messageQueue)
{
string readMessage = msg.Body.ToString();
MessageBox.Show(readMessage);
// process Message
}
// after all processing delete the messages
messageQueue.Purge();
MSMQ 메시지 보내는 방법 (0) | 2012.03.05 |
---|