Esempio n. 1
0
        public static void PublicMSMQ()
        {
            var msmqPaht = @".\myQueue";

            //连接到本地的队列
            var myQueue = MSMQHelper.CreateQueue(msmqPaht);

            Message myMessage = new Message();

            myMessage.Body = "423123";

            myMessage.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

            myQueue.Send(myMessage);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //#region         http://www.cnblogs.com/beniao/archive/2008/06/26/1229934.html

            //var msmqPaht = @".\private$\myQueue";

            ////连接到本地的队列
            //var myQueue = MSMQHelper.CreateQueue(msmqPaht);

            //Message myMessage = new Message();
            //myMessage.Body = "423123";

            //myMessage.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

            //myQueue.Send(myMessage);

            ////myQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });


            //Message myMessage2 = new Message();
            //myMessage2.Body = "523123";

            //myMessage2.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

            //myQueue.Send(myMessage2);

            // 清空队列的消息
            //myQueue.Purge();


            //删除现有的消息队列
            //MessageQueue.Delete(@".\private$\myQueue");



            //Message myMessage2 = myQueue.Receive();

            //string context = (string)myMessage2.Body;

            //Console.WriteLine("消息内容为:" + context);



            //GetAllMessage();

            //PublicMSMQ();

            //StartThreads();

            //SeneRemoteMessage();


            NetMQHelper netMqHelper = new NetMQHelper();

            netMqHelper.Init();


            MSMQHelper msmqHelper = new MSMQHelper();

            msmqHelper.Init();

            #region 升级

            //SendMessage(new Book() {
            //    BookAuthor="ffefe",
            //    BookId=23213,
            //    BookName="name",
            //    BookPrice=12.1

            //});


            //Console.WriteLine(ReceiveMessage());


            // 事务


            //TransactionSendQueue();

            //TransactionReceiveQueue();

            //SendMessageAnysc();
            //ReceiveMessageAsync();
            //#endregion

            //AsyncHelper asyncHlper = new AsyncHelper();

            //asyncHlper.Init();


            Console.ReadKey();
            #endregion
        }