Reputation: 3409
I writing a console app that add a message to local queue. But, no message is being inserted.
I created the queue as transactional and inserting like following:
string path = @"FormatName:DIRECT=OS:computername\private$\myqueue";
MessageQueue queue = new MessageQueue();
queue.Path = path;
foreach (string msg in messages)
{
queue.Send("inputMessage", msg);
}
Anything wrong with this?
Thanks.
Upvotes: 2
Views: 3703
Reputation: 2644
if you have transactional queues, make sure to check that you are using transactions
using(MessageQueueTransaction tx = new MessageQueueTransaction()) { tx.Begin(); queue.Send(message, tx); tx.Commit(); }
see more info in another post Message does not reach MSMQ when made transactional
Upvotes: 0
Reputation: 4687
Easy one, this. You are sending a non-transactional message to a transactional queue. MSMQ will discard the message.
Use the "MessageQueue.Send(Object, MessageQueueTransaction)" Method
If you enable Negative Source Journaling, you can look in the dead letter queue to see why messages gets discarded.
Cheers
John Breakwell
Upvotes: 7
Reputation: 983
try swapping the order on your send.
I'd have to double check but i'm pretty sure the order is object, label
queue.Send(msg, "inputMessage");
Upvotes: 0
Reputation: 498904
You need to create the queue before you can send to it (it's a one time operation, unless you delete the queue):
MessageQueue queue;
if (MessageQueue.Exists(path))
queue = new MessageQueue(path);
else
queue = MessageQueue.Create(path);
Upvotes: 2