在 IIS 6 中托管 MSMQ 并通过 WCF 向其发送消息

发布于 2024-12-08 06:57:06 字数 2157 浏览 1 评论 0原文

我想测试在可能连接或未连接的远程客户端上对消息进行排队的可能性,这些客户端在连接时会将消息推送到通过 Internet 发送到 IIS 6 中托管的 msmq。

现在,我在win server2003托管IIS。完成此操作后,“MSMQ”将显示在 IIS 默认网站中。

好吧,然后我通过计算机管理添加了一个新的事务私有队列->消息队列。

从那里我想做的就是看到消息堆积起来,我将在工作完成后处理这些消息。

现在,我制作了一个具有以下代码的客户端应用程序:

     using (var contract = new HttpMsmqBridgeProxy())
     {
        var valueToSend = 2456;
        contract.TestFunction(valueToSend);
        Console.WriteLine("value sent: " + valueToSend + "\r\n");
     }

这是该客户端的 app.config:

 <configuration>
  <system.serviceModel>
    <client>
      <endpoint
        address="net.msmq://**.**.***.228/private/MarksTestHttpQueue"
        binding="netMsmqBinding"
        bindingConfiguration="srmpBinding"
        contract="HttpMsmqBridgeLibrary.IHttpMsmqBridgeContract">
      </endpoint>
    </client>
    <bindings>
      <netMsmqBinding>
        <binding name="srmpBinding"
                 queueTransferProtocol="Srmp">
          <security mode="None"/>
        </binding>
      </netMsmqBinding>
    </bindings>
  </system.serviceModel>
</configuration>

该 IP 是我的面向公众的 IP,可以正常工作,我可以很好地托管 wcf 服务或网页。我在某种程度上遵循了本指南来使用 srmpBinding。

http://msdn.microsoft.com/en-us/library/aa395217.aspx

所以,简而言之,当我运行应用程序时会发生什么,它是否成功,告诉我它已发送,我进入客户端的消息队列,看到一个新队列已显示在“传出”文件夹中称为:

Direct:http://..*.228/msmq/private$/MarksTestHttpQueue

此队列中没有等待的传出消息,因此我假设消息已发送。

当我现在在 winserver2003 上查看我的 msmq 时,没有到达的排队消息在等待。

ETA:我可以使用经典的 MessageQueue 暗示将消息发送到非事务队列:

     var queue = new MessageQueue("FormatName:DIRECT=http://**.**.***.228/msmq/private$/nonTransQueue");
     System.Messaging.Message Msg;
     Msg = new System.Messaging.Message();
     Msg.Formatter = new ActiveXMessageFormatter();
     Msg.Body = "Testing";
     queue.Send(Msg);

消息显示(在修改 system32/msmq/mapping 目录中的映射文件之后)就好了。我想知道是否因为它是 IIS6 我无法使用 net.msmq 绑定发送。

I want to test out the possibility of queuing message on remote clients who may or may not be connected, those clients when connected will push the messages sent to an msmq over the internet that is hosted in IIS 6.

Now, I setup MSMQ on the win server2003 hosting IIS. After I did this "MSMQ" shows up in the IIS default web site.

Ok, then I added a new transactional private queue through computer management-> message queuing.

From there all I want to do is see messages stack up, I'll deal with those after this works.

Now, I made a client app that has the following code:

     using (var contract = new HttpMsmqBridgeProxy())
     {
        var valueToSend = 2456;
        contract.TestFunction(valueToSend);
        Console.WriteLine("value sent: " + valueToSend + "\r\n");
     }

Here's the app.config of this client:

 <configuration>
  <system.serviceModel>
    <client>
      <endpoint
        address="net.msmq://**.**.***.228/private/MarksTestHttpQueue"
        binding="netMsmqBinding"
        bindingConfiguration="srmpBinding"
        contract="HttpMsmqBridgeLibrary.IHttpMsmqBridgeContract">
      </endpoint>
    </client>
    <bindings>
      <netMsmqBinding>
        <binding name="srmpBinding"
                 queueTransferProtocol="Srmp">
          <security mode="None"/>
        </binding>
      </netMsmqBinding>
    </bindings>
  </system.serviceModel>
</configuration>

The IP is my public facing IP that works, I can host a wcf service or webpage just fine. I followed this guide somewhat for using srmpBinding.

http://msdn.microsoft.com/en-us/library/aa395217.aspx

So, in short what happens when I run the app is it succeeds, tells me it was sent, I go into Message Queue of my client and see that a new queue has shown up in Outgoing folder called:

Direct:http://..*.228/msmq/private$/MarksTestHttpQueue

there is no outgoing messages waiting in this queue so I assume the message was sent.

When I look at my msmq now on the winserver2003 there are no arrived queued messages waiting.

ETA: I can send messages to a non-transactional queue using the classic MessageQueue implimintation:

     var queue = new MessageQueue("FormatName:DIRECT=http://**.**.***.228/msmq/private$/nonTransQueue");
     System.Messaging.Message Msg;
     Msg = new System.Messaging.Message();
     Msg.Formatter = new ActiveXMessageFormatter();
     Msg.Body = "Testing";
     queue.Send(Msg);

The messages show up (after altering the mapping file in the system32/msmq/mapping directory) just fine. I'm wondering if because it's IIS6 I won't be able to send using the net.msmq binding.

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

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

发布评论

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

评论(1

七度光 2024-12-15 06:57:06

您是正确的,在 IIS6 中托管的 WCF 服务将无法处理消息。这是因为 IIS6 不使用 WAS 实例化非 http 请求的进程。但我认为这是在你在工作流程中所做的一切之后发生的。我期望

  • 您运行客户端,将消息推送到远程队列
  • 消息出现在远程队列中
  • 您的WCF服务不会拾取该消息,因为它托管在IIS6中,所以你在远程队列中留下了一条消息。

我不相信 IIS 会参与其中,直到它无法工作为止。

对此的一个简单测试是在服务器上自行托管您的服务,例如在控制台应用程序中运行它。它将能够像 IIS7 一样接受 MSMQ 消息,并将其作为潜在问题从您的设备中删除。

您可能还想测试是否可以将消息直接从客户端推送到服务器上的事务队列。如果您在向其他计算机上的事务队列发送消息时遇到问题,那么您可以检查 MSDTC 日志。我不羡慕必须深入那里。

You are correct in that your WCF service hosted in IIS6 won't be able to process the messages. This is because IIS6 doesn't use WAS which instantiates processes for non-http requests. But I think that this comes after everything you're doing in the workflow. I would expect

  • you run your client, pushing the message to the remote queue
  • the message appears in the remote queue
  • your WCF service does not pickup the message because it's hosted in IIS6, so you are left with a message in the remote queue.

I don't believe that IIS is involved at all up until the point where it wouldn't be working anyway.

A simple test for this is to self host your service on the server, e.g. run it in a console app. It will be able to accept MSMQ messages just as IIS7 would, and will remove that as a potential problem from your rig.

You might also want to test whether you can push a message directly from the client to a transactional queue on the server. If you're having problems sending messages to transactional queues on other machines then you can possibly check the MSDTC log. I don't envy having to delve into there.

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