Cannot determine whether a queue with the specified format name exists.

转载 2012年03月26日 22:07:14

Sometime back I had blogged about how to send messages to remote private queues. There were a few queries on how to read from remote queue as well.

To me it should have worked by using the MessageQueue.Receive API instead of .Send. I decided to give this a try anyway and it indeed is as trivial as that. However a few things to take care while trying to get this working.

1. Check the documentation to see where all the API works. The API may have limitations in working in workgroup mode if you are not using the direct format name syntax.

2. The other very important aspect is setting the formatter prior to receiving the message. You need to set this appropriately to binary or XML and specific type to ensure successful read.

To show a complete example, find below code that posts to the remote queue (transactional as well as non-transactional) and also reads from them. To keep things simple, I have used a simple string message here. However you can definitely use more complex types and custom types for sending and receiving (as long as they match both ways).

        private void btnPostToQueue_Click(object sender, EventArgs e)

        {

            //post to regular non-transactional remote queue using OS name

            MessageQueue rmQ =new MessageQueue("FormatName:Direct=OS:punhjw30076\\private$\\remote");

            rmQ.Send("sent to regular queue - Atul");

 

            //post to  transactional remote queue using IP address

            MessageQueue rmTxnQ =new MessageQueue("FormatName:Direct=TCP:100.100.100.12\\private$\\remoteTxn");

            rmTxnQ.Send("sent to transacted queue - Atul",MessageQueueTransactionType.Single);

        }

 

        private void btnGetFromQueue_Click(object sender, EventArgs e)

        {

            //retrieve from regular non-transactional remote queue using OS name

            MessageQueue rmQ =new MessageQueue("FormatName:Direct=OS:punhjw30076\\private$\\remote");

            rmQ.Formatter = newXmlMessageFormatter(newType[] { typeof(string) });

            System.Messaging.Message msg = rmQ.Receive();

            MessageBox.Show(msg.Body.ToString());

 

            //retrieve from transactional remote queue using IP address

            MessageQueue rmTxnQ =new MessageQueue("FormatName:Direct=TCP:100.100.100.12\\private$\\remoteTxn");

            rmTxnQ.Formatter = newXmlMessageFormatter(newType[] { typeof(string) });

            System.Messaging.Message msgTxn = rmTxnQ.Receive(MessageQueueTransactionType.Single);

            MessageBox.Show(msgTxn.Body.ToString());

        }

在调用远程的msmq是一定不要调用 MessageQueue.Exists(path) 、 mq = MessageQueue.Create(path, false);
举报

相关文章推荐

CGAL编译处理moc: Cannot open options file specified with @问题

CGAL编译处理moc: Cannot open options file specified with @问题

Maven test Exception:Another resource already exists with name xxx 已经解决

在run as Maven test出现以上Exception。
  • Lynch2
  • Lynch2
  • 2014-04-03 23:30
  • 2155

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

解决异常Unable to determine the provider name for connection of type SqlCeConnection的方法之一

最近开发一个带有local data的WPF项目时遇到一个异常:Unable to determine the provider name for connection of type 'System...

Passed-in Resource [resource loaded through InputStream] contains an open stream:cannot determine

Passed-in Resource [resource loaded through InputStream] contains an open stream2009-09-29 11:58 org...

How To Check Whether Physical Standby is in Sync with the Primary or Not?

The following tips will help you in monitoring sync between primary and standby databases. How To C...

解决tomcat6.0.33 配置SSL时报“No Certificate file specified or invalid file format”异常

在配置tomcat的SSL双向握手中,由于6.0.33版本中默认启用了APR(APR是通过JNI访问的可移植库,可以提高Tomcat的性能和伸缩性),所以采用传统的配置方式(如下)会报异常;   ...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)