使用 .NET 时 MSMQ 间歇性引发 IOException

发布于 2025-01-03 07:59:47 字数 1885 浏览 0 评论 0原文

MSMQ 出现间歇性问题,在发送到队列时生成 System.IO.IOException。我找不到任何关于此信息的信息,因此不确定为什么会发生这种情况(MSDN 文档甚至没有列出这个问题)。正如所说,它是间歇性的,因此调试它很困难,并且不会在开发环境中发生(仅在 QA 中)

堆栈跟踪:

   at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(System.CodeDom.Compiler.CompilerParameters, System.String[])
   at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(System.CodeDom.Compiler.CompilerParameters, System.String[])
   at System.Xml.Serialization.Compiler.Compile(System.Reflection.Assembly, System.String, System.Xml.Serialization.XmlSerializerCompilerParameters, System.Security.Policy.Evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(System.Xml.Serialization.XmlMapping[], System.Type[], System.String, System.Security.Policy.Evidence, System.Xml.Serialization.XmlSerializerCompilerParameters, System.Reflection.Assembly, System.Collections.Hashtable)
   at System.Xml.Serialization.TempAssembly..ctor(System.Xml.Serialization.XmlMapping[], System.Type[], System.String, System.String, System.Security.Policy.Evidence)
   at System.Xml.Serialization.XmlSerializer..ctor(System.Type, System.String)
   at System.Messaging.XmlMessageFormatter.Write(System.Messaging.Message, System.Object)
   at System.Messaging.Message.AdjustToSend()
   at System.Messaging.MessageQueue.SendInternal(System.Object, System.Messaging.MessageQueueTransaction, System.Messaging.MessageQueueTransactionType)
   at Test.MSMQWrite.WriteMessageInternal(System.String, System.Object, Boolean)
   at Test.Program.Main(System.String[])

WriteMessageInternal 的代码:

private static void WriteMessageInternal(string queueName, object data)
{            
    using (var queue = new MessageQueue(queueName, false, false, QueueAccessMode.Send))
    {                
        queue.Send(data);
    }
}

Having an intermittent issue with MSMQ where it generates System.IO.IOException when sending to queue. There isn't any information on this info I can find so not sure why it could be happening (MSDN documentation doesn't even list this an issue). As said it is intermittent so debugging it is hard and does not occur on dev environment (only in QA)

Stack Trace:

   at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(System.CodeDom.Compiler.CompilerParameters, System.String[])
   at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(System.CodeDom.Compiler.CompilerParameters, System.String[])
   at System.Xml.Serialization.Compiler.Compile(System.Reflection.Assembly, System.String, System.Xml.Serialization.XmlSerializerCompilerParameters, System.Security.Policy.Evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(System.Xml.Serialization.XmlMapping[], System.Type[], System.String, System.Security.Policy.Evidence, System.Xml.Serialization.XmlSerializerCompilerParameters, System.Reflection.Assembly, System.Collections.Hashtable)
   at System.Xml.Serialization.TempAssembly..ctor(System.Xml.Serialization.XmlMapping[], System.Type[], System.String, System.String, System.Security.Policy.Evidence)
   at System.Xml.Serialization.XmlSerializer..ctor(System.Type, System.String)
   at System.Messaging.XmlMessageFormatter.Write(System.Messaging.Message, System.Object)
   at System.Messaging.Message.AdjustToSend()
   at System.Messaging.MessageQueue.SendInternal(System.Object, System.Messaging.MessageQueueTransaction, System.Messaging.MessageQueueTransactionType)
   at Test.MSMQWrite.WriteMessageInternal(System.String, System.Object, Boolean)
   at Test.Program.Main(System.String[])

Code for WriteMessageInternal:

private static void WriteMessageInternal(string queueName, object data)
{            
    using (var queue = new MessageQueue(queueName, false, false, QueueAccessMode.Send))
    {                
        queue.Send(data);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文