MessageQueue : MessageQueue : Web Services C# Source Code


Custom Search

C# Source Code » Web Services » MessageQueue »

 

MessageQueue








    
 
using System;
using System.Messaging;

[Serializable]
class MyMessage {
    private string data;
    public MyMessage(string data) {
        this.data = data;
    }


    public override string ToString() {
        return data;
    }

}

class Program {
    static void Main(string[] args) {
        try {
            if (!MessageQueue.Exists(@".\Private$\MyPrivateQueue")) {
                MessageQueue.Create(@".\Private$\MyPrivateQueue");
            }
            MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");
            queue.Formatter = new BinaryMessageFormatter();

            queue.Send("Sample Message", "Label");

            MyMessage m = new MyMessage("xxx");
            queue.Send(m, "Binary Test");
        } catch (MessageQueueException ex) {
            Console.WriteLine(ex.Message);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Web Services
» MessageQueue