c# – 使用WCF的MSMQ监听器

有人知道如何使用WCF *实现MSMQ Listeners *吗?

解决方法

您无需在服务上手动实现队列侦听器.

只需创建服务操作合同,您就可以指定当消息到达队列时将调用的处理程序方法.

你可能(或应该)有这样的东西:

[OperationContract(IsOneWay = true,Action = "*")]
void HandleMyMessage (MsmqMessage<String> message);

这将确保在传递消息时将调用服务实现中的HandleMyMessage()方法.

UPDATE

在下面的评论中回答您的问题,要定义队列地址,您可以在< System.ServiceModel>中执行此操作.组态:

<services>
  <service 
      name="Microsoft.ServiceModel.Samples.OrderProcessorService"
      behaviorConfiguration="CalculatorServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
      </baseAddresses>
    </host>
    <!-- Define NetMsmqEndpoint -->
    <endpoint address="net.msmq://localhost/private/ServiceModelSamplesTransacted"
              binding="netMsmqBinding"
              contract="Microsoft.ServiceModel.Samples.IOrderProcessor" />
    <!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange" />
  </service>
</services>

从这里:http://msdn.microsoft.com/en-us/library/ms789032.aspx

相关文章

原文地址:http://msdn.microsoft.com/en-us/magazine/cc163...
前言 随着近些年微服务的流行,有越来越多的开发者和团队所采...
最近因为比较忙,好久没有写博客了,这篇主要给大家分享一下...
在多核CPU在今天和不久的将来,计算机将拥有更多的内核,Mic...
c语言输入成绩怎么判断等级
字符型数据在内存中的存储形式是什么