【问题标题】:Setting Recoverable attribute for MSMQ messages in PHP在 PHP 中设置 MSMQ 消息的可恢复属性
【发布时间】:2018-04-27 01:05:02
【问题描述】:

我想设置一个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); 

但它不起作用。我还尝试将布尔值设置为字符串值和整数,但没有一个起作用。 当我尝试 $msgOut->Recoverable = "true";$msgOut->Recoverable = true; 时,我得到了 com_exception

无法查找“可恢复”:未知名称。

【问题讨论】:

  • 试试Recoverable?
  • @LioraHaydont 修正了拼写,谢谢,但仍然返回错误。
  • 我以为这只是一个错字,但我想这不会那么容易:/

标签: php message-queue msmq


【解决方案1】:

没有可恢复的属性,所以这行是错误的:

$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); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-28
    • 1970-01-01
    • 2017-04-19
    • 2017-10-23
    • 2013-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多