1

I'm trying to send messages to MSMQ using PHP. When the message is smaller than approximately 1.1 MB the message is sent. Otherwise, I get exception "com_exception: There are insufficient resources to perform this operation." The message is smaller than the limit 4 MB. This is what I've found out so far:

  • file_get_contents and file_put_contents with PHP works with no problem, so upload limit should be fine
  • sending same message not with php works with no problem, so it is somehow PHP-related
  • purging messages from queue does not help
  • no dead-letter messages

php.ini settings:

  • upload_max_filesize=20M
  • memory_limit=512M

There is no limit on message size in msmq properties.

I'm uploading pdf files in file_get_contents. This is php for sending, the exception is on $msgOut->Send($msgQueue):

$body = file_get_contents("somefile.pdf");

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

$msgQueueInfo->PathName = $this->getPath();

if(!$msgQueue = new COM("MSMQ.MSMQQueue")){

        return false;
}


  $msgQueue=$msgQueueInfo->Open(MQ_SEND_ACCESS, MQ_DENY_NONE ); 

 if(!$msgOut = new COM("MSMQ.MSMQMessage")){

    return false;
  }           

  $msgOut->Body = $body; 
  $msgOut->Label = $this->getLabel();
  $msgOut->Send($msgQueue); 
  $msgQueue->Close();

  unset($msgOut);
  unset($msgQueue);
  unset($msgQueueInfo);
DropDropped
  • 1,253
  • 1
  • 22
  • 50
  • https://stackoverflow.com/questions/1732515/msmq-what-can-cause-a-insufficient-resources-to-perform-operation-error-when – James Apr 03 '18 at 12:35
  • @James thanks for the response. I've already checked the list, but I don't think any of that is the problem because it looks like the MSMQ is configured well - sending message with size 1.1 MB - 4MB doesn't work only with PHP. – DropDropped Apr 03 '18 at 12:39
  • Where are you getting the 1.1MB from? I assume this is the size of the raw data before being made into a message. What formatting are you using? Also, is it Unicode data? – John Breakwell Apr 05 '18 at 13:00
  • @JohnBreakwell it is just the estimation, as I've been trying multiple messages. I can get more accurate number if it is needed. I think that formatting is not set. I've added some code to the question. – DropDropped Apr 05 '18 at 13:13
  • @JohnBreakwell I think that it is because of the default encoding of the message. The file has around 2 million characters, and default encoding of the message is utf8. I've been trying to find a way how to specify an ascii encoding for the message with no success. – DropDropped Apr 06 '18 at 10:14
  • Found here someone sending data as a byte array to get single byte characters https://stackoverflow.com/questions/20052908/how-to-encode-an-msmq-message-as-utf8 – John Breakwell Apr 11 '18 at 08:59

0 Answers0