简体   繁体   中英

cannot send object over MSMQ inside WCF service

I've got some legacy code which sends objects over an MSMQ messagequeue. It worked fine but now the code is moved to a WCF service. Now suddenly limits are reached and the queue.Send line throws the exception:

"Insufficient resources to perform operation".

I'm not using netMsmqBinding, just sending it through MessageQueue objects so I dont know how to increase the quotum of the objects size.

MessageQueue queue = new MessageQueue(queueName);

using (MessageQueueTransaction tx = queue.Transactional ? new MessageQueueTransaction() : null)
{
    if (queue.Transactional)
    {
      tx.Begin();
    }

    Message msg = new Message();
    msg.Body = delivery;
    msg.Label = delivery.GetType().Name + " " + delivery.DeliveryId;
    msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(Delivery) });
    msg.Recoverable = true;
    queue.Send(msg, tx);
}

After implementing IErrorhandler on the service for logging exceptions I see this right before the resources:

12/10/2015 7:54:06 AM Uncaught exception of type System.TimeoutException was thrown. Message: 'The operation did not complete within the allotted timeout of 00:00:09.9970000. The time allotted to this operation may have been a portion of a longer timeout.'

I've put all the timeouts (open/close/receive/send) on the client and service to 45 minutes and still this error of 10 seconds timeout comes. Strange.

What can I do?

Found the cause of the problem, it was my own fault. I had removed [XmlIgnore] attribute from the two biggest members of Delivery. And since Delivery was serialized with XmlMessageFormatter for message queueing the object was simply too big for the queue.

Sorry to bother you....

The likely issue is that you are reaching the storage/memory limit of MSMQ (~2GB) due to 1 or more reasons.

  1. Messages are accumulating in one of your queues and are not being processed and removed. (Most likely)
  2. Journaling is turned on.
  3. Deadletter queues are filling up.

You can quickly check the queue sizes by checking the properties of the folder: %windir%\\system32\\msmq\\storage .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM