c# - 将消息放入 msmq,消息过期超时

标签 c# msmq

如果有一种开箱即用的方法可以将消息放入 msmq 并定义过期时间。 到期时我指的是以下情况:

  • 消息发送者非常频繁地将消息发送到队列中
message 1 published at 1:00
message 2 published at 1:02
message 3 published at 1:04
  • 消息接收者从队列中获取消息并运行一个耗时的过程

message 1 recieved at 1:00 and processed at 1:05

  • 根据应用程序逻辑,处理不早于特定时间范围的消息是有意义的

we shold process messages that are not older than 1 min so uder this requirement I wish that message 2 would disappeared from the queue

问题:

  • 我可以通过开箱即用的功能将其存档吗?
  • 如果不是?这样做的最佳做法是什么?
  • msmq 原则上是适用于此用例的正确技术吗?哪一个更适合要求?

最佳答案

Message 类有一个 TimeToBeReceived 属性(参见 MSDN )。我觉得应该可以满足你的要求。

此外,在我看来,您的系统无法以与生成消息相同的速度处理消息。 如果不了解有关系统的更多详细信息,很难说清楚,但可能值得探索并行使用消息的可能性(如果您还没有这样做的话)。

关于c# - 将消息放入 msmq,消息过期超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21047661/

相关文章:

c# - 当比较字段是动态的时,如何与 List<T> 中的上一个或下一个元素的属性进行比较?

c# - 通过主机文件连接到远程队列

wcf - System.ServiceModel.ServiceHost,处于Faulted状态,无法用于通信

c# - 错误: Message Queuing failed to verify digital signature of a message sent to queue

c# - 将嵌套结构从 C# 编码到 C++ DLL

c# - 从 SortedList 或 SortedDictionary 获取第 i 个值

visual-studio - 如何获取 msi(VS 安装项目)来安装 Windows 组件?

unit-testing - 使用 Visual Studio 测试套件/NUnit 自动化集成测试 MSMQ 的最佳方法是什么?

c# - Xamarin.Forms:Android <Entry> 和依赖服务?

c# - 在单元测试中创建 System.Web.Caching.Cache 对象