I am writing a Windows service that retrieves messages from MSMQ and sends them to a legacy system (Baan). If the message failed or the machine descended during the message, I do not want to lose the message. Therefore, I use MSMQ transactions. I abort failure, and I am sure of success.
When working with a local queue, this code works well. But in the production process, I want to separate the machine (or machines) that starts the service from the queue itself. When I test the remote queue, a System.Messaging.MessageQueueException error occurs: "Transaction usage is invalid."
I checked that the specified queue is transactional.
Here is the code that gets from the queue:
// Begin a transaction. _currentTransaction = new MessageQueueTransaction(); _currentTransaction.Begin(); Message message = queue.Receive(wait ? _queueTimeout : TimeSpan.Zero, _currentTransaction); _logger.Info("Received a message on queue {0}: {1}.", queue.Path, message.Label); WORK_ITEM item = (WORK_ITEM)message.Body; return item;
Answer
Since then, I have switched to SQL Service Broker . It supports remote transactional reception, while MSMQ 3.0 does not. And as an added bonus, he already uses an instance of SQL Server, which we are clustering and backing up.
Michael L Perry
source share