可嵌入队列?
我有一个应用程序,它收集操作并将它们发送到远程服务器。由于这些操作对时间要求不高(将它们视为日志行),因此我想将它们排队并批量发送。
这样,我还想确保不会丢失任何消息(除非硬盘驱动器崩溃)。
MSMQ 看起来相当重量级、神秘且使用起来很奇怪。此外,它需要作为系统组件安装。
将我的消息序列化为 JSON 并将它们存储在 SQLite 中是简单而直接的,但在我这样做之前,我想知道是否有一个标准化的(最好是 AMQP 兼容)队列,我不需要安装并且可以嵌入到应用程序中?
I have an Application that collects actions and sends them off to a remote server. As these actions aren't time critical (think of them as log lines), I want to queue them up and send them in batches.
That way, I also want to ensure that no message is ever lost (unless the hard drive crashes).
MSMQ seems rather heavyweight, arcane and weird to use. Also, it needs to be installed as a system component.
Serializing my messages into JSON and storing them in SQLite is trivial and straight forward, but before I do that, I wonder if there is a standardized (preferably AMQP compatible) queue that I doesn't require installation and can be embedded into an app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Graylog2 是一种集中式日志记录解决方案,它接受来自 AMQP 消息的日志条目。也许您可以根据您的用例进行调整。
无论如何,Graylog2 表明 AMQP 适用于收集日志消息之类的工作,而不会丢失任何消息。
AMQP 不需要安装,因为它是一个协议。您只需要 .NET 的客户端库。但是,您需要在 LAN 上某处的服务器上安装 MQ 代理来管理消息流。 RabbitMQ 因其易于安装而被广泛使用。
此外,一旦开始发送消息,那么您还需要在网络上的某个地方有一个进程,用于接收消息并对其执行某些操作,例如写入数据库。
Graylog2 is a centralized logging solution that accepts log entries from AMQP messages. Perhaps you could adapt it to your use-case.
In any event, Graylog2 shows that AMQP works for jobs like collecting log messages without losing any.
AMQP doesn't require installation, because it is a protocol. You just need the client library for .NET. However you would need to install an MQ broker on a server somewhere on your LAN to manage the message flow. RabbitMQ is widely used because it is easy to install.
Also, once you start sending messages, then you will also need to have a process somewhere on the network, that receieves them and does something with them such as write to a db.
如果您想要自制解决方案,您可以在日志服务器上安装 RabbitMQ,将 RabbitMQ 的 .NET 客户端嵌入到您的应用程序中,然后编写一个小程序来从队列中读取事件并将事件写入磁盘。
RabbitMQ 相当轻量:默认安装只有几 Mb,通常使用大约 11Mb 的内存来运行。它还提供了 AMQP 的扩展,Publisher Confirms,可用于确保一旦服务器接受日志消息后,它不会丢失,除非硬盘死掉。不过,该扩展是非标准的,并且其他经纪商可能不支持它。
If you want a homebrew solution, you could install RabbitMQ on the logging server, embed RabbitMQ's .NET client into your application, then write a small program to read from the queue and write the events to disk.
RabbitMQ is fairly lightweight: the default install is only a few Mb and it normally uses about 11Mb of memory to run. It also provides an extension to AMQP, Publisher Confirms, which can be used to ensure that once the server accepts the log message, it will not be lost, unless the hard disk dies. The extension is non-standard, though, and it's probably not supported by other brokers.
我真的认为你应该重新考虑 MSMQ。
我看到的唯一严重反对意见是必须安装 MSMQ。如果您必须在不同版本的 Windows 上广泛部署此应用程序,我认为这是一个重大问题。
I really think you should reconsider MSMQ.
The only serious objection that I can see is having to install MSMQ. If you are having to deploy this application far and wide on different versions of Windows, I can see that as a significant problem.