Setting Recoverable attribute for MSMQ messages in PHP

I would like to set the Recoverable attribute of the form message that I send to MSMQ. I was looking for some resources on how to do this in PHP, but I did not find them. I 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 that will not work. I also tried setting the boolean as a string value and an integer, but none of them worked. When I try $msgOut->Recoverable = "true"; or $msgOut->Recoverable = true; I got com_exception

Unable to search for `Recoverable ': Unknown name.

+5
source share
1 answer

There is no property to restore, so this line is incorrect:

 $msgOut->Recoverable = true; 

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

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

You can send the recovered message in this way:

 $msgOut->Body = $this->getBody(); $msgOut->Label = $this->getLabel(); $msgOut->Delivery = 1; $msgOut->Send($msgQueue); 
+3
source

Source: https://habr.com/ru/post/1273341/


All Articles