php - 在 PHP 中为 MSMQ 消息设置可恢复属性

标签 php message-queue msmq

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

相关文章:

php - shell - 代码是正确的,但不起作用

php - baseurl 不适用于 YII2

python - 使用工作池使用 Redis 消息

c# - 涉及 EntityFramework/SQL Server 和 NServiceBus/MSMQ 的分布式事务中的非同时提交

c - 创建MessageQueue时路径名非法

php - 如何存储 mcrypt_module_open ('rijndael-256' ,'' ,'ofb' ,'' );在MySQL中

javascript - jQuery 响应在 DreamWeaver 中工作,但在浏览器中不起作用

c# - 具有无限超时的 Peek MSMQ 消息

c++ - 通过消息队列发送缓冲区

scala - Akka:向持久邮箱添加延迟