Using PHP to open MSMQ queues

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

I think the main problem is

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

since I'm not sure what options 2, 0 mean (I can’t find a link to those where there are - I got this code from another example.) Looking at the documents for MSMQQueueInfo.open at http://msdn.microsoft. com / en-us / library / windows / desktop / ms707027% 28v = vs.85% 29.aspx I see several parameters, but not any numeric parameters.

Any help would be greatly appreciated. And the reason for integrating with MSMQ is to provide an intermediate solution when switching between systems, our old system uses MSMQ, so I need to have this interface.

thanks

+4
source share
1 answer

From here , you already know that the options are:

 Function Open(Access, ShareMode) 

and they also say that

Access can be set to one of the following values:

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

MQ_SEND_ACCESS: Messages can only be sent to the queue.

MQ_RECEIVE_ACCESS: messages can be restored (read and deleted) from the queue, peeked or cleared. See the description of the ShareMode argument for information on who can receive messages from the queue.

MQ_PEEK_ACCESS | MQ_ADMIN_ACCESS: Messages in the local outgoing queue can only be viewed (read without deleting from the queue).

MQ_RECEIVE_ACCESS | MQ_ADMIN_ACCESS: messages in the local outgoing queue can be received (read and deleted from the queue), peered at (read without deleting from the queue), or cleared (deleted).

In the MSDN docs for MQACCESS, they give numerical values ​​for constants:

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

The second parameter, ShareMode:

ShareMode indicates who can access the queue. Set one of the following values:

MQ_DENY_NONE: The default value. The queue is available to all members of the Everyone group. This parameter should be used if the Access parameter is set to MQ_PEEK_ACCESS or MQ_SEND_ACCESS.

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

These constants are:

 Const MQ_DENY_NONE = 0 Const MQ_DENY_RECEIVE_SHARE = 1 

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

+3
source

All Articles