php - 使用 PHP 打开 MSMQ 队列

标签 php msmq

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

我认为主要问题是

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

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

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

谢谢

最佳答案

来自 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 - 使用 PHP 打开 MSMQ 队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10400676/

相关文章:

php - 我应该关闭 cURL 吗?

msmq - 如何实现竞争性消费者解决方案?

javascript - AJAX/JQuery 中的 POST 请求 PHP 等效项

php - 自定义页面 GET 请求上的 Drupal 干净 url

c# - 如何将 msmq 消息移动到子队列

c# - 如何从收到的 msmq 消息中获取发件人的 WindowsIdentity?

c# - 为什么在使用 Powershell 方法时 MSMQ 上的消息计数返回 0?

c++ - 在 MSMQ 消息中发送具有 BSTR 值类型的 COM 对象

php - 从 PHP 创建、显示图像

php - 对记录集的每个可能组合执行...