My Profile

My photo
karachi, sindh, Pakistan
Networks Security Analyst

Thursday, January 7, 2010

Microsoft Messaging Queue

Environment:

 C# 2008
.net framework

 Last nite I was woking on final year project and I need to do a inter process communication. So my supervisor and my friend Mr. Qasim Pasta adviced me to do this with the help of using MSMQ.

 So here lis the code of using microsoft messsaging queue…

 By the help MSMQ you can easily communicate or transfer data from one application to another application..



 ENQUEUE OR A SENDER CODE

 /*********************************************************/

public
void Add_enqueue(string command)
{
string queueAdd = @".\Private$\Journal";
if (!MessageQueue.Exists(queueAdd))
 {
MessageQueue.Create(queueAdd);
 }
MessageQueue myQueue = new
MessageQueue(queueAdd);
myQueue.Send(command,"logs");

 }
/*********************************************************/


 DENQUEUE OR A RECIEVER CODE
/*********************************************************/

public
string Process_dequeue()
{
string queueAdd = @".\Private$\Journal";

if (!MessageQueue.Exists(queueAdd))
{
MessageQueue.Create(queueAdd);
}

MessageQueue _msgqueue = new
MessageQueue(queueAdd);
  _msgqueue.Formatter = new
XmlMessageFormatter(new
string[] { "System.String,mscorlib" });
  System.Messaging.Message[] _sysmsg = _msgqueue.GetAllMessages();
object o = new
object();
foreach (System.Messaging.Message m in _sysmsg)
{
o = m.Body;
  }
  _msgqueue.Purge();
string re = Convert.ToString(o);
return re;
  }

 /*********************************************************/

Tuesday, January 5, 2010

CCNP is on the way…

From last few days I was finding BSCI academy stuff but still I was unable to get it. L