Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing MSMQ over HTTP. How to address the queue?
    text
    copied!<p>I'm currently trying to use MSMQ with C# and .NET in order to achieve IPC. I am trying to understand how it works, and I'm quite confused about the <a href="http://blogs.msdn.com/b/johnbreakwell/archive/2009/02/26/difference-between-path-name-and-format-name-when-accessing-msmq-queues.aspx" rel="nofollow noreferrer">differences between Path name and Format name when accessing MSMQ queues</a>. I've found some similar issues in the following posts:</p> <ol> <li><a href="https://stackoverflow.com/questions/9488010/msmq-calls-over-http-not-reaching-destination-queue">MSMQ calls over HTTP not reaching destination queue</a></li> <li><a href="https://stackoverflow.com/questions/19156136/how-to-setup-msmq-server-so-that-it-can-be-accessed-over-the-internet">How to setup MSMQ server so that it can be accessed over the Internet</a></li> <li><a href="https://stackoverflow.com/questions/4499091/how-to-use-msmq-over-http-through-the-respective-wcf-binding">How to use MSMQ over http through the respective WCF binding?</a></li> </ol> <p>However, they're all using MSMQ and WCF, and I don't want to use WCF for now.</p> <p>What I want to achieve is the following:</p> <p><strong>Client:</strong> Sends data to the queue through <strong>http</strong>.</p> <p><strong>Server:</strong> Receives data from the queue through <strong>http</strong>.</p> <p>My point here is that I want that either <em>server, client and the queue</em> to be hosted in potentially different computers. (For now I'm testing everything in the same machine).</p> <p>Here I have the following code, which demonstrates what I have in mind:</p> <p>First, I create the queue:</p> <pre><code>if(!System.Messaging.MessageQueue.Exists(@".\Private$\SimplestExamplePrivateQueue"); System.Messaging.MessageQueue.Create(@".\Private$\SimplestExamplePrivateQueue"); </code></pre> <p><strong>Client code:</strong></p> <p>Then, at the client side, I have a callback function which is invoked when the user presses a button in order to send a message.</p> <pre><code>private void button1_Click(object sender, System.EventArgs e) { try { // Create a connection to the queue System.Messaging.MessageQueue mq = new System.Messaging.MessageQueue(@"FormatName:Direct=http://localhost/msmq/Private$/SimplestExamplePrivateQueue"); // Create a point object to send Point myPoint = new Point (Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text)) ; // Send object mq.Send (myPoint) ; } // Catch the exception that signals all types of error // from the message queueing subsystem. Report error // to the user. catch (System.Messaging.MessageQueueException mqx) { MessageBox.Show (mqx.Message) ; } </code></pre> <p>Everything until here works fine.</p> <p><strong>Server code:</strong></p> <p>Then, I have a button which invokes a callback function to synchronously read one message from the queue at the server side:</p> <pre><code>private void button1_Click(object sender, EventArgs e) { try { // Create a connection to the queue var mq = new MessageQueue(@"Direct=http://localhost/msmq/Private$/SimplestExamplePrivateQueue"); // Set the queue's formatter to decode Point objects mq.Formatter = new XmlMessageFormatter(new[] {typeof (Point)}); // Receive message synchronously Message msg = mq.Receive(); // Convert received message to object that we think was sent var pt = (Point) msg.Body; // Display it to the user MessageBox.Show(pt.ToString(), "Received Point"); } // Report any exceptions to the user. A timeout would cause such // an exception catch (Exception x) { MessageBox.Show(x.Message); } } </code></pre> <p>In my (limited) understanding of MSMQ, this should work. However, when I call <code>Message msg = mq.Receive();</code> I get the following exception:</p> <pre><code>The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted. </code></pre> <p>And the Stack Trace: </p> <pre><code>at System.Messaging.MessageQueue.MQCacheableInfo.get_ReadHandle() at System.Messaging.MessageQueue.StaleSafeReceiveMessage(UInt32 timeout, Int32 action, MQPROPS properties, NativeOverlapped* overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, IntPtr transaction) at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType) at System.Messaging.MessageQueue.Receive() at InternetQueueingRecipient.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\felipedalcin\Documents\MSMQ\MSMQandNET\InternetQueuing\InternetQueueingRecipient\Form1.cs:line 85 </code></pre> <p>Does anyone have an idea of how I could debug this or even if what I want to do is achievable by those means?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload