.net 中的 MSMQ 即服务
我们有一个 Java WebService,它使用 MSMQ 发送消息(带有一组记录的 XML 文件)。
我需要使用 VB.net 在 .net 中构建一个小型应用程序,它应该选择这些消息并读取它们并将其插入 SQL 数据库。
你们有什么建议吗? 我们如何实时读取MSMQ消息。
任何资源或链接都会有很大帮助。
We have a Java WebService which is sending messages(XML file with a set of records) using MSMQ.
I need to build a small application in .net using VB.net which should pick those messages and read them and insert into SQL database.
Do you guys have any suggestions? How can we read MSMQ messages on real time.
Any resources or links will be of great help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
系统中的 .NET 提供了 MSMQ 的完全托管实现.Messaging
命名空间。 您可以在消息队列上调用BeginReceive
,然后该队列将异步等待消息到达。 一旦完成,您就可以调用EndReceive,
处理消息并再次调用BeginReceive
以等待下一条消息(或处理队列中的下一条消息)。There's a full managed implementation of MSMQ available in .NET in the
System.Messaging
namespace. You can callBeginReceive
on a message queue, which will then asynchronously wait for a message to arrive. Once it does you can then callEndReceive,
process the message and callBeginReceive
again to wait for the next (or process the next in the queue).在 .NET 中处理 MSMQ 消息的最佳方法是使用 WCF。 Justin Wilcox 在此处提供了很棒的教程。
但我强烈建议你尝试MSMQ + WCF。 它非常好,您将了解有关 WCF 的更多信息,这是很棒的东西。
更简单的方法是像 JustinD 建议的那样做。 System.Messaging 命名空间非常易于使用。 我要做的唯一不同是调用 Receive 方法而不指定超时。 这会导致线程等待,直到消息出现在队列中,此时将收到消息。
The best way to process MSMQ messages in .NET is using WCF. Justin Wilcox has a great tutorial here.
But I strongly suggest you try MSMQ + WCF. It is very good and you'll learn more about WCF, which is great stuff.
The simpler way is to do something like JustinD suggests. The System.Messaging namespace is very easy to use. The only different I would make is to call the Receive method without specifying a timeout. This causes the thread to wait until a message appears in the queue, at which time is will be received.
这里有一些示例 C# .NET 代码,可以帮助您开始从队列中读取数据...
here's a bit of sample C# .NET code that may help get you started with reading from a queue...