New to MSMQ... My local queue never receives my test message. I have verified that Message Queuing and Message Queuing Triggers are running in my Services dialog (Vista Ultimate). Thoughts?
class ConsoleApplication
{
private const string Path = @".\private$\SomeQueue";
static void Main(string[] args)
{
var queue = !MessageQueue.Exists(Path)
? MessageQueue.Create(Path)
: new MessageQueue(Path) { Formatter = new BinaryMessageFormatter() };
queue.ReceiveCompleted += queue_ReceiveCompleted;
queue.BeginReceive();
queue.Send("test message");
Console.ReadLine();
queue.Close();
}
static void queue_ReceiveCompleted(object sender,
ReceiveCompletedEventArgs e)
{
Console.WriteLine("Received message...");
var queue = (MessageQueue)sender;
try
{
var message = queue.EndReceive(e.AsyncResult);
Console.WriteLine("Processing message...");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
queue.BeginReceive();
}
}
}
EDIT: Just had a thought, try deleting and re-creating the queue with MessageQueue.Delete(Path). And it worked. I guess my queue was hosed somehow.