使用PHP打开MSMQ队列
作者:互联网
我有一个示例PHP脚本连接到Windows上的MSMQ.我可以创建队列并向队列发送消息,但是当我尝试打开队列来读取消息时,我不断获得访问被拒绝的异常.代码在这里:
http://pastebin.com/S5uCiP2Z
我认为主要的问题是
$READ = $MSMQInfo->Open(2,0);
因为我不确定2,0选项代表什么(我无法找到任何地方的参考 – 我从另一个例子中获得了该代码.)在http://msdn.microsoft.com/en-us/library/windows/desktop/ms707027%28v=vs.85%29.aspx查看MSMQQueueInfo.open的文档我可以看到一些选项但是没有任何数字选项..
任何帮助将非常感激.与MSMQ集成的原因是在系统之间移动时提供临时解决方案,我们的旧系统使用MSMQ,因此我需要具有此接口.
谢谢
解决方法:
从here开始,您已经知道参数是:
Function Open(Access, ShareMode)
他们也这么说
Access can be set to one of the following:
MQ_PEEK_ACCESS: Messages can only be looked at. They cannot be removed from the queue.
MQ_SEND_ACCESS: Messages can only be sent to the queue.
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: Messages in the local outgoing queue can only be peeked at (read without being removed from the queue).
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文档中,它们为您提供常量的数值:
typedef enum
{
MQ_RECEIVE_ACCESS = 1,
MQ_SEND_ACCESS = 2,
MQ_PEEK_ACCESS = 0x0020,
MQ_ADMIN_ACCESS = 0x0080
} MQACCESS;
第二个参数,ShareMode:
ShareMode specifies who can access the queue. Set to one of the following:
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: 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
它确实有点难以找到,但你可以得到它,例如here,这不是一个可靠的来源,但我相信这是正确的.
标签:php,msmq 来源: https://codeday.me/bug/20190630/1333865.html