写入远程 MSMQ

发布于 2024-11-15 03:50:59 字数 150 浏览 1 评论 0原文

好的,这是一个非常简单且基本的问题。 如果我在 Windows 计算机 A 上有一个应用程序想要写入 Windows 计算机 B 上的队列,我是否需要在计算机 A 上安装 MSMQ(即使那里没有队列)?我刚刚开始在我的应用程序中使用队列,并试图弄清楚一些基本原理。

谢谢

Okay, here is a very simple and fundamental question.
If I have an application on windows machine A that wants to write to a queue on windows machine B, do I need to have MSMQ installed on machine A (even though there is no queue there)? I am just beginning to use queues for my applications and trying to figure some fundamentals out.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

沫离伤花 2024-11-22 03:50:59

是的,您需要在本地安装 MSMQ 才能写入远程队列。如果您要写入专用队列,请查看此页面 其中包含有关如何格式化队列名称的有用信息。如果您正在写入远程事务队列,那么您需要确保正确指定(第 5 点)

这是文章文本:

1.使用远程队列时,machinename\private$\queuename 格式的队列名称不起作用。这导致
“队列路径无效”错误。

2.队列名称必须以 FormatName:Direct=OS:machinename\\private$\\queuename 的形式提及。

这是必要的,因为队列访问是使用以下格式在内部完成的
仅名称语法。其他友好表示转换为
FormatName,然后使用。使用远程队列时,除非
有一个 AD 可以解析队列名称,友好名称不会
工作。查看文档了解详细信息。

例如。

MessageQueue rmQ = 新的 MessageQueue 
              ("FormatName:Direct=OS:机器名\\private$\\queue");
rmQ.Send("发送到常规队列-Atul");

3.继续上一点,请注意 FormatName 区分大小写。如果您将前面的字符串提到为
FORMATNAME:Direct=OS:machinename\\private$\\queuename,不会
工作。令人惊讶的是,在这种情况下没有抛出任何错误。
字符串的“FormatName”部分似乎是唯一区分大小写的
部分。其他的可能会出现在不同的情况下。例如。你可以写
“直接的”。

4.如果您想使用计算机的 IP 地址,语法将为 FormatName:Direct=TCP:ipaddress\\private$\\queuename

例如。

MessageQueue rmQ = 新的 MessageQueue
              ("FormatName:Direct=TCP:121.0.0.1\\private$\\队列");
rmQ.Send("发送到常规队列-Atul");

5.您在代码中创建的队列实例的事务属性应与您尝试发送的队列的事务属性相匹配
留言至.因此,在前面的示例中,我向
非事务队列。要发送到事务队列,代码
将会是

MessageQueue rmTxnQ = 新的 MessageQueue
            ("FormatName:Direct=OS:机器名\\private$\\queue");
rmTxnQ.Send("发送到 Txn 队列 - Atul", MessageQueueTransactionType.Single);

如果事务属性不匹配,则不会发送消息
发表。令人惊讶的是,我没有收到任何错误,并且
消息就这样消失了

6.最后,当您将消息发送到远程队列时,会在您自己的计算机上创建一个临时的传出队列。这用于以下情况
远程队列不可用。如果你进入计算机管理
控制台 (compmgmt.msc),然后展开服务和应用程序/
消息队列/传出队列,您会看到这些队列。这
控制台右侧应显示包括状态在内的详细信息
(连接或未连接)以及下一跳的 IP 地址。

Yes, you need MSMQ installed locally to write to a remote queue. If you're writing to a private queue, take a look at this page which has useful information on how to format the queue name. If you're writing to a remote Transactional queue, then you need to make sure you specify that correctly (point 5)

This is the article text:

1. When working with remote queues, the queue name in the format machinename\private$\queuename doesn't work. This results in an
"invalid queue path" error.

2. The queue name has to be mentioned as FormatName:Direct=OS:machinename\\private$\\queuename.

This is necessary since the queue access is internally done using the format
name syntax only. The other friendly representation is converted to
the FormatName and then used. When working with remote queues, unless
there is an AD to resolve the queue name, the friendly name won't
work. Check out documentation for details.

For Eg.

MessageQueue rmQ = new MessageQueue 
              ("FormatName:Direct=OS:machinename\\private$\\queue");
rmQ.Send("sent to regular queue - Atul");

3. Further to previous point, note that FormatName is case sensitive. If you mention the earlier string as
FORMATNAME:Direct=OS:machinename\\private$\\queuename, it won't
work. Surprisingly, there is no error thrown in this case.
"FormatName" part of the string seems to be the only case sensitive
part. Others can appear in different case. For eg. You can write
"DIRECT".

4. In case you want to use the machine's IP address the syntax will be FormatName:Direct=TCP:ipaddress\\private$\\queuename.

For Eg.

MessageQueue rmQ = new MessageQueue
              ("FormatName:Direct=TCP:121.0.0.1\\private$\\queue");
rmQ.Send("sent to regular queue - Atul");

5. The transactional properties of the queue instance you create in code should match with that of the queue you are trying to send the
message to. So in the earlier examples, I was sending message to a
non-transactional queue. To send to a transactional queue, the code
would be

MessageQueue rmTxnQ = new MessageQueue
            ("FormatName:Direct=OS:machinename\\private$\\queue");
rmTxnQ.Send("sent to Txn queue - Atul", MessageQueueTransactionType.Single);

If the transactional properties don't match, the message will not be
delivered. The surprising part is again, I didn't get any error, and
the message just disappeared

6. Finally, when you send messages to remote queue, a temporary outgoing queue is created on your own machine. This is used in case
the remote queue is unavailable. If you go to the computer Management
console (compmgmt.msc), and expand the Services and Applications /
Message Queuing / Outgoing Queues, you would see these queues. The
right side of the console should show the details including the state
(connected or not) and the IP address(es) for the next hop(s).

人心善变 2024-11-22 03:50:59

所有 MSMQ 通信的每一端都需要一个 MSMQ 队列管理器。
使用 MSMQ 的应用程序与其本地队列管理器进行通信,后者为它们完成工作。
使用 MSMQ 的应用程序无法直接与任何本地或远程队列通信。

All MSMQ communication requires an MSMQ queue manager at each end.
MSMQ-using applications communicate with their local queue manager which does the work for them.
MSMQ-using applications cannot communicate directly with any queues, local or remote.

软糯酥胸 2024-11-22 03:50:59

另一种方法(而不是在运行客户端的本地计算机上安装 MSMQ)是实现从 MSMQ 队列获取消息的 WCF 服务。在这种情况下,您的远程客户端只需指定远程服务端点即可直接写入远程队列。您还必须小心远程队列的安全设置是否正确。

我认为这将是实现基于队列的通信的更好方法。这是一个简短的答案,但如果您感兴趣,我会很乐意扩展(我注意到您对其他答案非常满意:)

Another (instead of installing MSMQ on the local machine running the client) would be to implement a WCF service which takes its messages from an MSMQ queue. In that case, your remote client would only have to specify the remote service endpoint for it to write directly to the remote queue. You would also have to be careful that the security on the remote queue was set correctly.

I think this would be a better way of implementing queue-based communication. This is a short answer, but I will happily expand if you're interested (I noticed that you were pretty happy with the other answer :)

埖埖迣鎅 2024-11-22 03:50:59

以下格式对我们有用

key="PublicQueueName" value="FormatName:Direct=TCP:192.168.12.58\private$\myqueue"

此外,您还需要授予远程队列访问权限

安全性:允许匿名登录

在此处输入图像描述

below format worked for us

key="PublicQueueName" value="FormatName:Direct=TCP:192.168.12.58\private$\myqueue"

Also you would require to give remote queue access permissions

security: Allow Anonymus login

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文