Hey all,
I'm trying to run the MSMQ+WCF samples at http://code.msdn.microsoft.com/msmqpluswcf on Windows 7 and the messages that the client sends with MSMQ don't end up in the queue and no exception is generated.
If I dig through the queue object in debugger after a send, i find the "Access To Message Queue System Denied" but no exception is raised. Also, if I stop MSMQ entirely I still get this message after a send and no exception.
I googled around but with no luck.
Any ideas?
If you download the sample and try to run that code is it working for you? (you have to create the MSMQOrders queue)
Thanks in advance,
Serban
The "Access To Message Queue System Denied" was on the read handler because i was creating the queue in send mode.
The problem was taht the queue was not transactional and on send i was passing the MessageQueueTransactionType.Single parameter.
The removal of MessageQueueTransactionType.Single when calling the send method solved the problem.
Related
I have some code that sends a message to a remote queue.
var queue = new MessageQueue(queueName);
var message = new Message(queueMessage, new BinaryMessageFormatter());
queue.Send(message);
I've tried setting the queue using IP and hostname, it makes no difference:
FormatName:Direct=TCP:1.2.3.4\Private$\my.queue
FormatName:Direct=OS:servername\Private$\my.queue
The messages appear in the outgoing messages queue (if I pause it)
When unpaused they're sent to the server.
There is a private queue set up on the server. There is nothing running that will take messages off the queue.
However, messages never appear in the queue on the remote machine. I don't know how to debug this problem. The queue is a private non-transactional queue.
Creating a local private queue and sending messages to it works fine.
Are there some logs or something I can look at to see what might be happening?
The status in outgoing messages shows state as 'connected' so there is no connection issue.
Edit:
The only logging I can find is in event viewer > microsoft > windows > msmq which has an entry that simply says "Message came over network" whenever I send a message via MSMQ. It has no other information.
Solved, I added this:
message.UseDeadLetterQueue = true;
This made the server put it into the dead letter queue under System Queues > Dead-letter messages
Once this happened I could see my message and clicking it, it said 'Access Denied' under the 'Class' heading.
A quick google revealed that even though I had granted Everyone full access permissions to the queue, it was necessary to add Anonymous Logon and give that full access too in the security tab of the queue.
I have a WebJob getting messages from Service bus which is working fine. If the webjob fails to finish or throws exception the message is sent back in the queue which is fine in itself.
I have set MaxDequeueCount to 10 and it is not a problem if it fails in some cases as it will try to process it again. But the problem is that the message seems to be sent to the bottom of the queue and other messages are handled before we get back to the first failed one.
I would like to handle one message at a time because I might have multiple updates on the same entity coming in a row. If the order changes it would update the entity in wrong order.
Is if it is possible to send the message back infront of the queue on error or continue working on the same message until we reach the MaxDequeueCount?
Ideally, you should not be relying on message order.
Given your requirement, you could potentially go with the FIFO semantics of Azure Service Bus Sessions. When a message is handled within a session and message is aborted, it will be handled once again rather than go to the end of the queue. You need to keep in mind the following:
Can only process one message at a time
Requires session to be used
If message is not completed and not aborted, it will be left hanging in the queue and will be picked up when a session is restarted.
Preamble:
I have a web application, which sends MSMQ messages (with UseDeadLetterQueue = true) from time to time. I can also see that some of those messages are put into a system dead letter queue. However, I can't see the failure reason directly from "Computer Management" console.
I found the following resource:
https://msdn.microsoft.com/en-us/library/ms789035(v=vs.110).aspx,
which allows to check message status and failure. But it's usable only in WCF scope (as it uses OperationContext).
Basically checking message status and failure reason is what I need, but how can I configure a WCF service to listen to a dead-letter queue and track all the messages put inside, regardless of sender?
Or is there any other (non-WCF) way to get reason of why specific message was put into a dead letter queue?
The linked article you found tells you how to create a WCF service that takes messages off the DLQ. Note that it tells you you must use AddressFilterMode = AddressFilterMode.Any to pull all messages off regardless of sender.
Note: by the time the message ends up on the DLQ, you will not have information about the reason this occurred. Regardless of whether or not you're using WCF that information isn't stored in the queue.
If for example your recipient is a WCF listener using the MSMQ binding any exception thrown will cause the message to fail to get delivered. MSMQ will retry for a while and then eventually give up and put the message in the DLQ. So if you wanted to know the original reason you need to add some tracing in your WCF service to catch and trace thrown exceptions.
Im trying to pull messages from a queue of the MSMQ service. It works great in one service but in the other it fails to create a queue if it not exists. the line that fails is:
_cursor = _queue.CreateCursor();
Where CreateCursor is a method of the MessageQueue class.
The exception is:
Message Queue service is not available
If you need more information let me know.
Thanks in advance.
The problem was that I ran the service in debug mode. When I compiled it and ran in Release mode the problem solved. It seems that queues' creation permission depends on the compilation type of the solution.
I'm trying to create message queue:
MessageQueue.Create(path, true);
And I'm getting the following exception:
The queue does not exist or you do not have sufficient permissions to
perform the operation.
But queue was created in spite of exception. I tried several times:
Remove queue
Invoke create method
Exception occurs
Queue was created.
Could someone tell me the reason of exception? How can I avoid it?
Edited:
I tried on different machine. The same behavior.
OS: Windows 7. Console application. Runned by user with admin rights.
I found how it can be avoided.
Path was equal to #"**localhost**\Private$\Queue".
I changed it to #"**.**\Private$\Queue" and the exception disappeared.
But the reason is still unclear.