简体   繁体   中英

No message in msmq

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.

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

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);

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

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM