【发布时间】:2015-12-10 18:10:36
【问题描述】:
我有一些遗留代码通过 MSMQ 消息队列发送对象。它运行良好,但现在代码已移至 WCF 服务。现在突然达到限制并且 queue.Send 行抛出异常:
“资源不足,无法执行操作”。
我没有使用 netMsmqBinding,只是通过 MessageQueue 对象发送它,所以我不知道如何增加对象大小的配额。
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);
}
在服务上实现 IErrorhandler 以记录异常后,我在资源之前看到了这一点:
12/10/2015 7:54:06 AM 未捕获的类型异常 System.TimeoutException 被抛出。消息:'操作没有 在 00:00:09.9970000 的分配超时时间内完成。时间 分配给该操作的可能是较长时间的一部分 超时。'
我已将客户端和服务上的所有超时(打开/关闭/接收/发送)设置为 45 分钟,但仍然会出现 10 秒超时的错误。奇怪。
我能做什么?
【问题讨论】:
-
听起来您的 MSMQ 存储已达到 ~2 gig 限制。您是否有任何包含大量消息的队列?需要注意的是,MSMQ 不适用于长期存储。它是一个队列,永远不应该保留排队的项目。添加消息后,它应该几乎立即被另一个进程拾取。
-
@Servé Laurijssen 你使用什么绑定?如果 NetTcpBinding 你可以 // QUOTAS binding.MaxConnections = 200; binding.ListenBacklog = 800; binding.MaxBufferSize = Int32.MaxValue; binding.MaxReceivedMessageSize = Int32.MaxValue; binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue; binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue; binding.ReaderQuotas.MaxDepth = 128; binding.ReaderQuotas.MaxBytesPerRead = 4096;
-
@Serve`Laurijseen - 对不起我的错 - 在重新阅读你的帖子后 - 我漱口并来到一个链接:blogs.msdn.com/b/johnbreakwell/archive/2006/09/18/… 和 support.microsoft.com/en-us/kb/899613
-
对象有多大? MSMQ 消息最大为 4MB。
-
你在服务端使用netMsmqBinding吗?