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.
Related
As we have moved from NSB5 to NSB6 we also looked into removing NServiceBus.Host and instead use Topshelf. When we did, our service no longer shows that it has stopped when we receive a critical failure.
As an example, when we have trouble to reach the database for any reason I want the service to end and in Services Manager it should indicate not running. Though, it still says running but service is actually stopped. Therefore no recovery is run either.
This was working as we were using NServiceBus.Host.
I was looking in the wrong direction, towards Topshelf. The answer lies in how to configure NServiceBus to take care of critical errors.
EndpointConfiguration.DefineCriticalErrorAction(OnCriticalError);
and
private async Task OnCriticalError(ICriticalErrorContext context)
{
await context.Stop().ConfigureAwait(false);
}
This worked for me.
We're using ActiveMQ locally to transfer data between 5 processes that turn simultaneously.
I have some data I need to send to a process, both at runtime (which works perfectly fine), but also a default value on start. Thing is it is published when the process starts, it just doesn't read because it wasn't subscribed to the topic at the time the data was sent.
I have multiple solutions : I could delay the first publishing for a moment so that the process has time to launch (which doesn't seem very appealing) ; or is there a way to send all stored previously non-treated messages to some process that just subscribed ?
I'm coding in C#.
I don't have any experience with ActiveMQ, but other message system usually have an option which marks the subscription as persistent, which means that; after the first subscription; the message queue itself checks if a certain message is delivered to that system and retries with a timeout. In this scenario you need to start the receiver at least 1 time.
If this is not an option and you want to plug in receiver afterwards, you might want to consider a setup of your messages which allows you to retrieve the full state, i.e. if you send total-messages instead of differential- messages.
After a little google, I came upon this definition durable subscribers, I hope this helps:
See:
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
and
http://activemq.apache.org/manage-durable-subscribers.html
since you are using C# client i don't konw if this is supported
topic = new ActiveMQTopic("TEST.Topic?consumer.retroactive=true");
http://activemq.apache.org/retroactive-consumer.html
So, another solution is to configure this behavior on the broker side by adding that to the activemq.xml and restart :
The subscription recovery policy allows you to go back in time when
you subscribe to a topic.
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<subscriptionRecoveryPolicy>
<timedSubscriptionRecoveryPolicy recoverDuration="10000" />
<fixedCountSubscriptionRecoveryPolicy maximumSize="10000" />
</subscriptionRecoveryPolicy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
http://activemq.apache.org/subscription-recovery-policy.html
I went around the issue by sending a message from each process when they're launched back to the main one, and then only sending the info I needed to send.
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.
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.
At the moment I have a C# service that is reading messages off the queue (Websphere MQ) and writing them in a database.
Everytime I do a GET the message dissappears from queue. I would like an additional functionality though. I prefer to read a message off the queue and remove it in from the queue only after the write in the database was succesful. Please note I do all these in a multithreaded application. I know there is a way to browse the queue but this doesn't really provide the functionality I need.
I'm writing my firts WMQ application, and I know I'll run into this issue very soon, so I found your question.
I've found this http://www.mqseries.net/phpBB2/viewtopic.php?t=43043&sid=11ad2d587dbd19056836ccc3f8943e5f (specifing MQOO_BROWSE option while opening the queue) in other forum, I haven't tried it yet, but it think it worth a try...
[]'s
I have implemented similar functionality in C++. Hopefully this helps you or someone.
You can browse messages without removing them from the queue using options MQGMO_BROWSE_FIRST and MQGMO_BROWSE_NEXT.
How do I browse a Websphere MQ message without removing it?
Store message identifiers in a list or in any other suitable data structure.
Write messages to the database.
Then get messages from the queue normally without BROWSE option. ImqQueue::Get takes two parameters: options and ImqMessage. Set message identifier to ImqMessage-class before calling get. ImqMessage acts as a filter. You can select
only those messages that have been written successfully to the database.
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.amqzan.doc%2Fuc10330_.htm