Microsoft Message Queues – Private Queue Gotchas

I have just developed an application hosted on Windows 2003 Server that employs MSMQ 3.0 technology to manage transactions from a web service.

I created a function to create a private queue and used the samples in MSDN.

When I tried to view the queue from within MMC, I found that I did not have access, even though I was an Administrator. I got messages to do with opening a “Security Descriptor”. Googling for this problem revealed similar problems but no solution.

So I checked out the MessageQueue Class in MSDN and found the culprit. I needed to grant explicit access rights at creation. Thus the code is as follows:

Private Sub Init()
Dim QueueFromWeb As String = “.\private$\OnlineSalesInbound”
Dim QueueToWeb As String = “.\private$\OnlineSalesOutbound”
Dim QueueInbound As MessageQueue = New MessageQueue(QueueFromWeb)
Dim QueueOutbound As MessageQueue = New MessageQueue(QueueToWeb)
If Not MessageQueue.Exists(QueueFromWeb) Then
QueueInbound.Label = QueueFromWeb
QueueInbound.Authenticate = False
QueueInbound.SetPermissions(“MyDomain\Domain Admins”, MessageQueueAccessRights.FullControl)
QueueInbound.MessageReadPropertyFilter.CorrelationId = True
QueueInbound.UseJournalQueue = True
End If
If Not MessageQueue.Exists(QueueToWeb) Then
QueueOutbound.Label = QueueToWeb
QueueOutbound.Authenticate = False
QueueOutbound.SetPermissions(“MyDomain\Domain Admins”, MessageQueueAccessRights.FullControl)
QueueOutbound.UseJournalQueue = True
End If
End Sub

The addition of the bolded code fixed the problem.

Technorati tags:


One thought on “Microsoft Message Queues – Private Queue Gotchas

  1. Wow! This could be one particular of the most helpful blogs We’ve ever arrive across on this subject. Basically Wonderful. I’m also a specialist in this topic therefore I can understand your hard work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s