什么用于 C# 消息传递
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What to use for Messaging with C#
提问by Kevin Sheffield
So my company stores alot of data in a foxpro database and trying to get around the performance hit of touching it directly I was thinking of messaging anything that can be done asynchronously for a snappier user experience. I started looking at ActiveMQbut don't know how well C# will hook with it. Wanting to hear what all of you guys think.
因此,我的公司在 Foxpro 数据库中存储了大量数据,并试图绕过直接接触它的性能影响,我正在考虑向任何可以异步完成的消息发送消息,以获得更快速的用户体验。我开始研究ActiveMQ,但不知道 C# 将如何与它挂钩。想听听大家的看法。
edit : It is going to be a web application. Anything touching this foxpro is kinda slow (probably because the person who set it up 10 years ago messed it all to hell, some of the table files are incredibly large). We replicate the foxpro to sql nightly and most of our data reads are ok being a day old so we are focusing on the writes. plus the write affects a critical part of the user experience (purchasing), we store it in sql and then just message to have it put into foxpro when it can. I wish we could just get rid of the foxpro, unfortunately the company doesn't want to get rid of a very old piece of software they bought that depends on it.
编辑:这将是一个网络应用程序。任何接触这个 foxpro 的东西都有点慢(可能是因为 10 年前设置它的人把它搞砸了,有些表格文件非常大)。我们每晚都将 foxpro 复制到 sql 中,我们的大部分数据读取都可以在一天之内完成,因此我们专注于写入。加上写入会影响用户体验(购买)的关键部分,我们将其存储在 sql 中,然后在可能的情况下将其放入 foxpro 中。我希望我们可以摆脱foxpro,不幸的是,该公司不想摆脱他们购买的依赖于它的非常旧的软件。
采纳答案by Nathan
ActiveMQ works well with C# using the Spring.NET integrations and NMS. A post with some links to get you started in that direction is here. Also consider using MSMQ (The System.Messaging namespace) or a .NET based asynchronous messaging solution, with some options here.
ActiveMQ 使用 Spring.NET 集成和 NMS 与 C# 配合良好。一些链接的支撑柱,让你在这个方向开始就在这里。还可以考虑使用 MSMQ(System.Messaging 命名空间)或基于 .NET 的异步消息传递解决方案,这里有一些选项。
回答by Ed.
Sorry if this isn't what you are asking for... Have you considered some sort of cache behind the scenes that acts a bit like the "bucket system" when using asynchronous sockets in c/c++ using winsock? Basicly, it works by accepting requests, and sends an immediate response back to the web app, and when it finally gets around to finding your record, it updates it on the app via AJAX or any other technology of your choice. Since I'm not a C# programmer I can't provide any specific example. Hope this helps!
对不起,如果这不是你所要求的......当使用winsock在c/c++中使用异步套接字时,你有没有考虑过某种幕后的缓存,它有点像“存储桶系统”?基本上,它的工作原理是接受请求,并将立即响应发送回 Web 应用程序,当它最终找到您的记录时,它会通过 AJAX 或您选择的任何其他技术在应用程序上更新它。由于我不是 C# 程序员,因此无法提供任何具体示例。希望这可以帮助!
回答by SarekOfVulcan
Does the Fox app use .CDX indexes? If so, you might be able to improve performance by adding indexes without needing to change any program code. If it uses .IDX indexes, though, the change would have to be done in the actual app.
Fox 应用程序是否使用 .CDX 索引?如果是这样,您也许能够通过添加索引来提高性能,而无需更改任何程序代码。但是,如果它使用 .IDX 索引,则必须在实际应用程序中进行更改。
回答by James Strachan
Its worth mentioning that the ActiveMQ open source projectdefines a C# API for messaging called NMSwhich allows you to develop against a single C# / .Net API that can then use various messaging back ends such as
值得一提的是,ActiveMQ 开源项目定义了一个用于消息传递的C# API,称为 NMS,它允许您针对单个 C#/.Net API 进行开发,然后可以使用各种消息传递后端,例如
- ActiveMQ
- MSMQ
- TibCo's EMS
- any STOMP provider
- any JMS provider via StompConnect
- ActiveMQ
- MSMQ
- TibCo 的 EMS
- 任何 STOMP 提供者
- 通过StompConnect 的任何 JMS 提供程序
回答by James Strachan
As the problem is with writes, I would look more towards >removing< any unneeded indexes on the tables. As is common in RDBMS, every index on a FoxPro table slows down a write operation as the indexes need to be updated, and as you aren't reading directly from (or presumably directly querying) the table you shouldn't need very many indexes. You might also want to look at any triggers or field rules on the tables as they may be slowing down the write operation. Be sure your referential integrity is still preserved, though..
由于问题在于写入,我会更多地关注>删除<表上任何不需要的索引。正如在 RDBMS 中常见的那样,FoxPro 表上的每个索引都会减慢写入操作,因为索引需要更新,并且由于您不是直接从(或可能直接查询)表中读取数据,因此您不需要太多索引. 您可能还想查看表上的任何触发器或字段规则,因为它们可能会减慢写入操作的速度。不过,请确保您的参照完整性仍然保留。
回答by James Strachan
MSMQ (Microsoft Message Queueing) may be a great choice. It is part of the OS and present as an optional component (can be installed via Add/Remove Programs / Windows Components), meaning it's free (as long you already paid for Windows, of course). MSMQ provides Win32/COM and System.MessagingAPIs. More modern Windows Communication Foundation (aka Indigo) queued channelsalso use MSMQ. Note that MSMQ is not supported on Home SKUs of Windows (XP Home and Vista Home)
MSMQ(Microsoft Message Queueing)可能是一个不错的选择。它是操作系统的一部分并作为可选组件出现(可以通过添加/删除程序/Windows 组件安装),这意味着它是免费的(当然,只要您已经为 Windows 付费)。MSMQ 提供 Win32/COM 和System.MessagingAPI。更现代的 Windows Communication Foundation(又名 Indigo)排队通道也使用 MSMQ。请注意,Windows 的 Home SKU(XP Home 和 Vista Home)不支持 MSMQ
回答by James Strachan
You may want to look at MSMQ. It can be used by .NET and VFP, but you'll need to rewrite to use them. Here's an article that tells you how to use MSMQ from VFP. https://docs.microsoft.com/en-us/previous-versions/visualstudio/foxpro/ms917361(v=msdn.10)
您可能想查看 MSMQ。它可以由 .NET 和 VFP 使用,但您需要重写才能使用它们。这里有一篇文章告诉您如何从 VFP 使用 MSMQ。https://docs.microsoft.com/en-us/previous-versions/visualstudio/foxpro/ms917361(v=msdn.10)