关闭

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

标签: documentationstringtypesobjectapi
3028人阅读 评论(1) 收藏 举报
分类:

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);
0
0
查看评论
发表评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

学习maven的各种问题

之前学习的时候网上找的资料,依旧各种乱,反正都弄下来了。  Maven常见问题解决 1. The container 'Maven Dependencies' references non...
  • natian306
  • natian306
  • 2014-04-09 09:26
  • 56237

Android开发笔记(成长轨迹)

1.控制台输出:called unimplemented OpenGL ES API 调用了未实现的OpenGL ES API函数,一般由于导入的第三方库如地图库,里面有用到OpenGL,但是模拟器...
  • mad1989
  • mad1989
  • 2013-06-21 09:44
  • 126296

weblogic部署项目问题-Java/Web开发

转自:http://biancheng.dnbcw.info/java/124491.html   首先我说下我的部署环境和开发模式:部署环境是MyEclipse+Weblogic9i,开发环境是...
  • arlanhon
  • arlanhon
  • 2014-06-16 23:30
  • 2347

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

CGAL编译处理moc: Cannot open options file specified with @问题
  • wsh6759
  • wsh6759
  • 2011-11-17 11:30
  • 2140

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

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

Determine if a Directory Exists

  • 2006-02-23 09:05
  • 1KB
  • 下载

Determine if a File Exists

  • 2006-02-23 09:05
  • 1KB
  • 下载

解决异常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...
  • Neils03
  • Neils03
  • 2012-07-16 14:01
  • 3428

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...
  • pianistOfSoftware
  • pianistOfSoftware
  • 2016-07-13 14:35
  • 452

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...
  • xiangsir
  • xiangsir
  • 2014-04-08 16:36
  • 1401
    个人资料
    • 访问:4052315次
    • 积分:44298
    • 等级:
    • 排名:第89名
    • 原创:420篇
    • 转载:612篇
    • 译文:1篇
    • 评论:218条
    最新评论