ASP.NET Podcast

ASP.NET Podcast is geared towards the Microsoft .NET Framework and ASP.NET.
The podcast is run by Wally McClure, David Penton, and Paul Glavich.
Welcome to ASP.NET Podcast Sign in | Join | Help
in Search

ASP.NET Podcast

The ASP.NET Podcast features, technical talks, interviews, news, reviews, and Wallyisms. Wallace B. (Wally) McClure and Paul Glavich are your hosts.

ASP.NET Podcast Show #33 - MSMQ

ASP.NET Podcast – Show #33

 

Subscribe


This show is available in the subscription feed.

 

Show Notes:

Welcome to the First Show of 2006.

More Wally in your life.

Got my MVP Award for 2006.  I go off on a tangent about what an MVP is.

I got a really cool laptop bag as a present.

The “Beginning AJAX with ASP.NET” book is coming along.  Paul, Scott, and I are hard at work.

Who is Bruce Dickenson and why does he send me strange emails?  Do you know why?

What do words mean in IT?

  • Strategic.
  • Tactical.
  • Opportunity.
  • “Stepping up to the plate.”
  • “Stepping into one”/”Taking one for the team.”

 

MSMQ

Class:

        [Serializable()]

        public class cSearchResults

        {

            public string Url = String.Empty;

            public string ServerName = String.Empty;

            public long Id = 0;

            public string UrlText = String.Empty;

            public DateTime DateSearched;

        }

 

Sending a Message:

Simple:

      public static void StoreSearchUrl( string pstrCn, string pstrUrl )

            {

                  MessageQueue mq = new MessageQueue(gstrQueueForSearchUrl);

                  mq.Send(pstrUrl);

                  mq.Dispose();

                  mq = null;

            }

 

Class:

            MessageQueue mq = new MessageQueue(gstrQueueForSearchResults);

            cSearchResults objRes = new cSearchResults();

            try

            {

                  objRes.UrlText = pText;

                  objRes.Url = pstrUrl;

                objRes.Id = plngUrl;

                objRes.DateSearched = DateTime.Now;

                mq.Send(objRes);

            }

            finally

            {

                  mq.Dispose();

                  mq = null;

            }

 

Receiving a Message:

Simple:

                gMQSearchUrl = new MessageQueue();

                gMQSearchUrl.Path = gstrQueueForSearchUrl;

                gMQSearchUrl.Formatter = new XmlMessageFormatter(new string[] { "System.String, mscorlib" });

                gMQSearchUrl.ReceiveCompleted += new ReceiveCompletedEventHandler(this.MQ_ReceiveCompleted_ForSearchUrl);

                gMQSearchUrl.BeginReceive();

...............

private void MQ_ReceiveCompleted_ForSearchUrl(object sender, ReceiveCompletedEventArgs e)

{

      // Add code here to respond to message.

      //new XmlMessageFormatter(new String(){"System.String, mscorlib"});

      System.Messaging.Message msg = gMQSearchUrl.EndReceive(e.AsyncResult);

      msg.Formatter = new XmlMessageFormatter(new String[]{"System.String, mscorlib"});

      string strBody = (string)msg.Body;

      try

      {

            StoreUrlInSearchUrl(strBody);

      }

            //Exception handling code

      finally

      {

            if ( this.gblRunStatus == true )

            {

                  gMQSearchUrl.BeginReceive();

            }

            msg.Dispose();

            msg = null;

      }

 

Class:

                gMQSearchResults = new MessageQueue();

                gMQSearchResults.Path = gstrQueueForSearchResults;

                gMQSearchResults.Formatter = new XmlMessageFormatter(new Type[] { typeof(WebSearch.cSearchResults) });

                gMQSearchResults.ReceiveCompleted += new ReceiveCompletedEventHandler(this.MQ_ReceiveCompleted_ForSearchResults);

                gMQSearchResults.BeginReceive();

........................

        private void MQ_ReceiveCompleted_ForSearchResults(object sender, ReceiveCompletedEventArgs e)

        {

            // Add code here to respond to message.

            System.Messaging.Message msg = gMQSearchResults.EndReceive(e.AsyncResult);

            WebSearch.cSearchResults cSearchRes;

            try

            {

                  msg.Formatter = new XmlMessageFormatter(new Type[] {typeof(WebSearch.cSearchResults)}); //= new XmlMessageFormatter(new Type() {GetType(WebSearchSupport.cSearchResults)}); //new XmlMessageFormatter(new String(){"System.String, mscorlib"});

                  cSearchRes = (WebSearch.cSearchResults)msg.Body;

                  StoreUrlInSearchResults(cSearchRes);

            }

                  //Exception handling code

            finally

            {

                  msg.Dispose();

                  msg = null;

                  if ( this.gblRunStatus == true )

                  {

                        gMQSearchResults.BeginReceive();

                  }

            }

 

        }

Published Tuesday, January 10, 2006 3:43 PM by admin
Anonymous comments are disabled

This Blog

Syndication

Powered by Community Server, by Telligent Systems