Archive

Posts Tagged ‘queue management’

Messaging Queues

February 17th, 2009

Message queuing is used in scenarios where we need a failsafe mechanism while two processes communicate with each other. Microsoft has provided MSMQ for implementing message queues. MSMQ is essentially a messaging protocol that allows applications running on disparate servers to communicate in a failsafe manner. A queue is a temporary storage where one process can store messages and the other process can retrieve those. In this way, implementing a producer/consumer mechanism. This ensures that messages are not lost even if the systems are not connected for some time period.

There are different type of queues as mentioned in the table below:

Queue Type Description
Public queue Registered in directory services, can be located by any Message Queuing applications
Private queue Registered on local machine, typically cannot be located by other applications
System Queue These are system level queues.

Let’s look how you may create a queue.

  1. Open the computer management snap-in.
  2. Navigate to the [Message Queuing] node under the Services and Applications node.
  3. Right click on the [Private Queues] and in the context menu select New -> Private Queue.
  4. Name the queue msmq_web as shown in the figure below:

Once you have created this queue, it will be shown in the snap-in. Now we can write and read messages from this queue. Download the code at the end of this article, it consists of a web application. The web application contains two buttons. One is “Send Message”, as soon as you click on it a message is recorded in the msmq_web queue. You can configure your message in the web.config. When you click the second button “Consume Message”, one message is consumed from msmq_web queue and recorded in the database. You can find the code to record and retrieve messages from a queue. The application is shown in the figure below:

Download code here:

.Net , , , , , ,


Copyright © 2006-2011 W@rfi