Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Recoverable attribute for MSMQ messages in PHP

I'd like to set a Recoverable attribute form messages which I'm sending to MSMQ. I've been searching some resources how to do this in PHP but I haven't found any. I've tried this

    if(!$msgOut = new COM("MSMQ.MSMQMessage")){
        return false;
    }           

    $msgOut->Body = $this->getBody(); 
    $msgOut->Label = $this->getLabel();
    $msgOut->Recoverable = true;
    $msgOut->Send($msgQueue); 

but it does not work. I've also tried to set the boolean as a string value and integer but none of it worked. When I try $msgOut->Recoverable = "true"; or $msgOut->Recoverable = true; I got com_exception

Unable to lookup `Recoverable': Unknown name.

like image 737
DropDropped Avatar asked Oct 17 '22 03:10

DropDropped


1 Answers

There is no recoverable property, so this line is wrong:

$msgOut->Recoverable = true;

According the documentation of the class MSMQMessage, the property name should be "Delivery" and value is MQMSG_DELIVERY_RECOVERABLE:

public const int MQMSG_DELIVERY_EXPRESS = 0;
public const int MQMSG_DELIVERY_RECOVERABLE = 1;

You can send recoverable message in this way:

$msgOut->Body = $this->getBody(); 
$msgOut->Label = $this->getLabel();
$msgOut->Delivery = 1;
$msgOut->Send($msgQueue); 
like image 51
Krivers Avatar answered Oct 21 '22 09:10

Krivers