holly_cheng
holly_cheng

Reputation: 2481

Cannot read from MSMQ on local machine

I have a public message queue on my local machine that I created with my user account. I have a Windows service also on my local machine that runs under a corporate service account. I have granted the service account full access to the queue, and yet when the service is running, it can't seem to read the messages on the queue. I feel like I'm missing something rather basic, but I haven't been able to figure out what it is.

Code:

string queuePath = "FormatName:DIRECT=TCP:127.0.0.1\MyQueue";
MessageQueue _queue = new MessageQueue(queuePath);

When I step through the code, after the _queue object is created, the CanRead property is always false. I've tried several different ways of setting the queue path ("DIRECT=OS:.\MyQueue", "PUBLIC=[guid]", and without using a format name as well), but nothing has been successful.

The MSDN documentation states that "CanRead is false if a queue is already open with exclusive read access (or if it's open with non-exclusive access and this MessageQueue requests exclusive access), or if the application does not have sufficient rights to access it."

I've made sure that the application has sufficient rights (I think), but how can I tell if something else has "exclusive read access" to it? Is there anything else I'm missing?

Thanks.

Upvotes: 0

Views: 1739

Answers (1)

tom redfern
tom redfern

Reputation: 31780

Why are you using public queues? You should try re-create the queue as private (queue address will change to FORMATNAME:DIRECT=TCP:127.0.0.1\PRIVATE$\MyQueue) and see if this resolves your issue.

I have been using MSMQ for five years and have never used a public queue. I don't actually understand what they're for. But from experience people who try to use them usually have much more difficulty around authentication.

Upvotes: 2

Related Questions