Friday, April 8, 2011

MSMQ

MessageQueue messageQueue = null;
if (MessageQueue.Exists(@".\Private$\MyTestingQueues"))
{
messageQueue =
new MessageQueue(@".\Private$\MyTestingQueues");
messageQueue.Label = "Testing Queue 1";
Message objMsg = new Message ();
objMsg.Label = "Test Label";
objMsg.Body = "Content 1";
//messageQueue.Send(objMsg);
//TEST
CondoEntity objEntity = new CondoEntity();
objEntity.ListingGUID = Guid.NewGuid();
objEntity.Name = "test";
messageQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(CondoEntity) });
messageQueue.Send(objEntity);
}
else
{
// Create the Queue
MessageQueue.Create(@".\Private$\MyTestingQueues");
messageQueue = new MessageQueue(@".\Private$\MyTestingQueues");
messageQueue.Label = "Newly Created Queue";
}
messageQueue.Send("First ever Message is sent to MSMQ", "Title");

No comments:

Post a Comment