Reputation: 41
I'm trying to send messages to Microsoft Message Queuing (MSMQ) from PHP (version 7).
Could anyone provide me with code examples or point me to relevant documentation or libraries that can be used to send messages to MSMQ with PHP?
Any help or guidance would be greatly appreciated. Thank you in advance!
Upvotes: 1
Views: 72
Reputation: 41
I Have Solve it and here are the solution that can be use in this kind of problem.
<?php
define("MQ_SEND_ACCESS", 2);
define("MQ_DENY_NONE", 0);
try {
$msgQueueInfo = new COM("MSMQ.MSMQQueueInfo");
$msgQueueInfo->PathName = ".\\private$\\messages";
$msgQueue = $msgQueueInfo->Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
if (!$msgQueue) {
throw new Exception("Failed to open the queue.");
}
$msgOut = new COM("MSMQ.MSMQMessage");
$msgOut->Body = "It's my first commit";
$msgOut->Send($msgQueue);
$msgQueue->Close();
unset($msgOut);
unset($msgQueue);
unset($msgQueueInfo);
echo "Message sent successfully.";
} catch (Exception $e) {
echo "An error occurred: " . $e->getMessage();
}
?>
Upvotes: 3