我想设置一个 Recoverable attribute形成我发送到 MSMQ 的消息。我一直在搜索一些资源如何在 PHP 中执行此操作,但我还没有找到任何资源。这个我试过了
if(!$msgOut = new COM("MSMQ.MSMQMessage")){
return false;
}
$msgOut->Body = $this->getBody();
$msgOut->Label = $this->getLabel();
$msgOut->Recoverable = true;
$msgOut->Send($msgQueue);
但它不起作用。我还尝试将 bool 值设置为字符串值和整数,但都不起作用。
当我尝试 $msgOut->Recoverable = "true";
或 $msgOut->Recoverable = true;
我得到 com_exception
Unable to lookup `Recoverable': Unknown name.
最佳答案
没有可恢复的属性,所以这行是错误的:
$msgOut->Recoverable = true;
根据类的文档MSMQMessage ,属性名称应为“Delivery”,值为 MQMSG_DELIVERY_RECOVERABLE :
public const int MQMSG_DELIVERY_EXPRESS = 0;
public const int MQMSG_DELIVERY_RECOVERABLE = 1;
您可以通过这种方式发送可恢复的消息:
$msgOut->Body = $this->getBody();
$msgOut->Label = $this->getLabel();
$msgOut->Delivery = 1;
$msgOut->Send($msgQueue);
关于php - 在 PHP 中为 MSMQ 消息设置可恢复属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47279744/