1 / 22

Microsoft Message Queues MSMQ

Microsoft Message Queues MSMQ. Brian Francis NCR Corporation WROX Press. Agenda. What is Messages Queuing Why use Message Queuing Working with Queues and Messages. What is Messages Queuing. Message queuing is a system that allows different applications to communicate with each other.

Albert_Lan
Download Presentation

Microsoft Message Queues MSMQ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft Message QueuesMSMQ Brian Francis NCR Corporation WROX Press

  2. Agenda • What is Messages Queuing • Why use Message Queuing • Working with Queues and Messages

  3. What is Messages Queuing • Message queuing is a system that allows different applications to communicate with each other. E-mail for Applications

  4. Message Queues • Message Content • Message Data - Application Specific • Sender, Receiver, Timestamp, Expiration • Message Queue • Like a Post Office Box

  5. Why use Message Queuing • Distributed Systems • Communication Speed • MSMQ vs. COM

  6. Distributed Systems • Network-centric Applications • Non-permanent connections • Disconnected users

  7. Communication Speed • TCP is faster, but the connection HAS TO BE reliable… • Faster connections => more expensive connections

  8. MSMQ vs. COM • Synchronous Operations • All systems connected via fast links • Familiar programming model

  9. When to use MSMQ • If the application you are communicating with is not running at the same time as your application, use message queuing… • If the message is important and will cause problems if it is lost, use message queuing… • If your application is not always connected to receiver application, but still needs to be functional, use message queuing... • And if you perform many communication tasks with other application asynchronously, and may or may not care about their response, use message queuing…

  10. Working with Queues and Messages • MSMQ Object Model • MSMQ from ASP Pages • MSMQ from ASP VB Components

  11. MSMQ Object Model

  12. MSMQ for ASP Pages • Declare our variables • Loop through the queues • Peek at the first message • Display its label • Peek for any more messages • Move onto the next queue

  13. Declare our variables • Declare Variables and Create Obejcts <% Option Explicit Dim query Set query = Server.CreateObject("MSMQ.MSMQQuery") Dim qinfos, qinfo, queue, msg Dim arQueues arQueues = Array("OrderReady", "PackingSlip", _ "PendingOrder", "OrderPicking") Dim strQueueName

  14. Loop through the queues • For each queue, create a table and populate with list of contained messages Response.Write "<TABLE WIDTH="95%"><TR>" For Each strQueueName In arQueues Response.Write "<TD valign=top><TABLE BORDER=1>_ <TR><TH>" & strQueueName & "</TH></TR>" & vbCrLf set qinfos = query.LookupQueue(,,strQueueName) qinfos.Reset Set qinfo = qinfos.Next If IsObject(qinfo) Then

  15. Peek at the first message • Check to see if there is a message in the queue – PeekCurrent to set cursor position • If not, display Queue Empty message Set queue = qinfo.Open(MQ_PEEK_ACCESS, MQ_DENY_NONE) Set msg = queue.PeekCurrent(100, False, False) If msg Is Nothing Then Response.Write "<TR><TD>Queue Empty</TD></TR>" _ & vbCrLf Else Do While Not (msg Is Nothing)

  16. Display its label • The Order Number is stored in the label field, so display it. Response.Write "<TR><TD>“ & msg.Label & _ "</TD></TR>" & vbCrLf

  17. Peek for any more messages • Use the PeekNext to check for the next message in the queue Set msg = queue.PeekNext(50, False, False) Loop End If End If

  18. Move onto the next queue • End the table for the current queue, then move on to the next queue Response.Write "</TABLE></TD>" & vbCrLf Next Response.Write "</TR></TABLE>" & vbCrLf %>

  19. MSMQ for ASP VB Components • Create the Project • Set References • Implement ObjectControl • Common Helper Functions • Posting to a queue • Retrieving from a queue • Use in ASP

  20. Building the VB Component - Show Example -

  21. References • Professional ASP Components • Professional ASP 3.0 • http://www.asptoday.com

  22. Q & A • Questions? • Email - bfrancis@mindspring.com

More Related