使用PHP打开MSMQ队列 [英] Using PHP to Open MSMQ Queues

查看:201
本文介绍了使用PHP打开MSMQ队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个示例php脚本,用于连接Windows上的MSMQ.我可以创建队列并将消息发送到队列,但是当我尝试打开队列以读取消息时,我不断收到访问被拒绝"异常.代码在这里: http://pastebin.com/S5uCiP2Z

I have a sample php script to connect to MSMQ on windows. I can create queues and send messages to the queues, however when i try and open the queue to read the messages I keep getting an Access denied exception. the code is here: http://pastebin.com/S5uCiP2Z

我认为主要问题是

$READ = $MSMQInfo->Open(2,0);

line,因为我不确定2、0选项代表什么(我无法在任何地方找到对它们的引用-我从另一个示例中获得了该代码.)在 http://msdn.microsoft.com/zh-我们/library/windows/desktop/ms707027%28v=vs.85%29.aspx 我可以看到一些选项,但看不到任何数字选项.

line as i am unsure what the 2, 0 options stand for (i cannot find an reference to those any where - i got that code form another example.) Looking at the docs for MSMQQueueInfo.open at http://msdn.microsoft.com/en-us/library/windows/desktop/ms707027%28v=vs.85%29.aspx I can see a few options but not any numeric options..

任何帮助将不胜感激.与MSMQ集成的原因是在系统之间移动时提供一个临时解决方案,我们的旧系统使用MSMQ,所以我需要具有此接口.

Any help would be vastly appreciated. And the reason for integrating with MSMQ is to provide an interim solution whilst moving between systems, our old system uses MSMQ so i need to have this interface.

谢谢

推荐答案

来自

From here, you already know the parameters are:

Function Open(Access, ShareMode)

他们也说

访问权限可以设置为以下之一:

Access can be set to one of the following:

MQ_PEEK_ACCESS:只能查看消息.无法将它们从队列中删除.

MQ_PEEK_ACCESS: Messages can only be looked at. They cannot be removed from the queue.

MQ_SEND_ACCESS:消息只能发送到队列.

MQ_SEND_ACCESS: Messages can only be sent to the queue.

MQ_RECEIVE_ACCESS:可以从队列中检索(读取和删除),查看或清除消息.有关限制谁可以从队列中检索消息的信息,请参见ShareMode参数的描述.

MQ_RECEIVE_ACCESS: Messages can be retrieved (read and removed) from the queue, peeked at, or purged. See the description of the ShareMode argument for information on limiting who can retrieve messages from the queue.

MQ_PEEK_ACCESS | MQ_ADMIN_ACCESS:只能查看本地传出队列中的消息(读取时不会将其从队列中删除).

MQ_PEEK_ACCESS | MQ_ADMIN_ACCESS: Messages in the local outgoing queue can only be peeked at (read without being removed from the queue).

MQ_RECEIVE_ACCESS | MQ_ADMIN_ACCESS:可以检索(从队列中读取和删除)本地消息队列中的消息,对其进行窥视(读取而不将其从队列中删除)或清除(删除).

MQ_RECEIVE_ACCESS | MQ_ADMIN_ACCESS: Messages in the local outgoing queue can be retrieved (read and removed from the queue), peeked at (read without being removed from the queue), or purged (deleted).

在MSDN上的 MQACCESS 它们为您提供了常数的数值:

In MSDN's docs for MQACCESS they give you the numerical values for the constants:

typedef  enum 
{
  MQ_RECEIVE_ACCESS = 1,
  MQ_SEND_ACCESS = 2,
  MQ_PEEK_ACCESS = 0x0020,
  MQ_ADMIN_ACCESS = 0x0080
} MQACCESS;

第二个参数,ShareMode:

The second parameter, ShareMode:

ShareMode指定谁可以访问队列.设置为以下之一:

ShareMode specifies who can access the queue. Set to one of the following:

MQ_DENY_NONE:默认.该队列可用于所有人"组的所有成员.如果将Access设置为MQ_PEEK_ACCESS或MQ_SEND_ACCESS,则必须使用此设置.

MQ_DENY_NONE: Default. The queue is available to all members of the Everyone group. This setting must be used if Access is set to MQ_PEEK_ACCESS or MQ_SEND_ACCESS.

MQ_DENY_RECEIVE_SHARE:将可以从队列中检索消息的用户限制为该进程.如果已经打开队列以通过另一个进程检索消息,则此调用失败,并生成MQ_ERROR_SHARING_VIOLATION(0xC00E0009)错误.仅在Access设置为MQ_RECEIVE_ACCESS时适用.

MQ_DENY_RECEIVE_SHARE: Limits those who can retrieve messages from the queue to this process. If the queue is already opened for retrieving messages by another process, this call fails and an MQ_ERROR_SHARING_VIOLATION (0xC00E0009) error is generated. Applicable only when Access is set to MQ_RECEIVE_ACCESS.

这些常量是:

Const MQ_DENY_NONE = 0
Const MQ_DENY_RECEIVE_SHARE = 1

确实很难找到它,但是您可以在此处上找到它,但这不是非常可靠的消息来源,但我相信这是正确的.

it's indeed a little harder to find, but you can get it for example here, which is not much a reliable source, but I believe it's correct.

这篇关于使用PHP打开MSMQ队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆