使用 Websphere MQ 主题 .NET API
我读了这篇文章< /a>
并且仍然不理解主题在 MQ 中如何工作的概念。 在 JMS 中,我知道您可以在主题上发布消息,并且为了从中接收消息,您首先需要订阅它(在接收阶段使用订阅名称)。
MQ 中是如何工作的?我想写一个简单的场景(如在 JMS 中):
示例代码 (.NET) 会很有帮助
盖伊
I read this article
And still didn't understand the notion of how topics works in MQ.
In JMS I know that you can publish a message on a Topic, and in order to receive a message from it you first need to subscribe to it (using the subscription name at the receive phase).
How it is work in MQ? I want to write a simple scenario of (as in JMS):
A sample code (.NET) would be helpful
Guy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您看过包含的示例代码吗?在默认安装中,它位于:
C:\Program Files\IBM\WebSphere MQ\tools\dotnet\samples
MQPubSubSample.cs
程序说明了托管和非托管代码的持久和非持久订阅。在每种情况下,它首先订阅,然后发布,但您可以轻松地将其修改为问题中所述的发布/订阅/接收/发布/接收的用例。 (不过,您将无法从尚未订阅的主题接收信息。)以下是示例代码中的其中一个部分:
您的问题引用了 JMS 作为示例。请注意,您可以选择使用 IBM XMS - 适用于 .Net 的可扩展消息服务客户端。 XMS 通过 .Net 实现 JMS API,使用 WMQ、WMB 或 WAS 作为传输,因此您只需很少的修改即可使用 JMS 代码。 消息服务客户端对于 .Net 2.0.0 手册描述了该产品:
.NET 消息服务客户端
.NET 消息服务客户端提供了一个称为 XMS 的应用程序编程接口 (API),它具有与 Java 消息服务 (JMS) API 相同的一组接口。 .NET 消息服务客户端包含完全托管的 XMS 实现,任何 .NET 兼容语言都可以使用它。
XMS 支持:
XMS 应用程序可以与以下类型的应用程序交换消息:
程序 XMS 应用程序可以连接到以下任何消息传递服务器并使用其资源:
通过连接到 WebSphere MQ 队列管理器,XMS 应用程序可以使用 WebSphere MQ Enterprise Transport 与 WebSphere Event Broker 或 WebSphere Message Broker 的代理进行通信。或者,XMS 应用程序可以使用 WebSphere MQ 发布/订阅代理。
如果您希望进一步探索,示例 XMS 代码位于前面提到的本机 .Net 示例下方的子目录中。 使用手册的 XMS 示例应用程序部分。
自 v7 起,.Net 支持已集成到 WMQ 中。如果您缺少示例,那么您的 WMQ 客户端安装是后级的或安装不完整。适用于 Windows 的最新 v7.0 WMQ 客户端可通过 SupportPac MQC7 下载。
XMS 支持作为 SupportPac IA9H 提供。
Have you looked at the included sample code? In a default installation it resides at:
C:\Program Files\IBM\WebSphere MQ\tools\dotnet\samples
The
MQPubSubSample.cs
program illustrates both durable and non-durable subscriptions for managed and unmanaged code. In each case it first subscribes, then publishes but you can easily modify it to your use case of publish/subscribe/receive/publish/receive as described in the question. (You won't be able to receive from a topic to which you have not yet subscribed, though.)Here's one of the sections from the sample code:
Your question references JMS as an example. Please be aware that you have the option of using IBM XMS - Extensible Message Service Client for .Net. XMS implements the JMS API over .Net with WMQ, WMB or WAS as the transport so you can use JMS code with very little modification. The Message Service Client for .Net 2.0.0 manual describes the offering:
Message Service Client for .NET
Message Service Client for .NET provides an application programming Interface (API) called XMS that has the same set of interfaces as the Java Message Service (JMS) API. Message Service Client for .NET contains a fully managed implementation of XMS, which can be used by any .NET compliant language.
XMS supports:
An XMS application can exchange messages with the following types of application:
An XMS application can connect to, and use the resources of, any of the following messaging servers:
By connecting to a WebSphere MQ queue manager, an XMS application can use WebSphere MQ Enterprise Transport to communicate with a broker of WebSphere Event Broker or WebSphere Message Broker. Alternatively, an XMS application can use a WebSphere MQ Publish/Subscribe broker.
If you wish to explore further, the sample XMS code resides in subdirectories below the native .Net samples referred to earlier. The samples are described in the Using the XMS Sample Applications section of the manual.
The .Net support is integrated into WMQ as of v7. If you are lacking the samples then your WMQ client installation is back-level or incompletely installed. The latest v7.0 WMQ Client for Windows is downloadable as SupportPac MQC7.
The XMS support is delivered as SupportPac IA9H.