MSMQ Listeners using WCF

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


You do not need to manually implement a queue listener on your service.

Simply by creating your service operation contract you are specifying the handler method which will be called when a message arrives on the queue.

You probably (or should) have something like this:

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

This will ensure that the method HandleMyMessage() in your service implementation will be called when a message is delivered.

UPDATE

In response to your question in the comment below, to define the queue address you can do this in the <System.ServiceModel> configuration:

<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>

From here: http://msdn.microsoft.com/en-us/library/ms789032.aspx


MSMQ binding is possible on WCF. You can refer to http://blogs.msdn.com/b/tomholl/archive/2008/07/12/msmq-wcf-and-iis-getting-them-to-play-nice-part-1.aspx to get more ready information.

链接地址: http://www.djcxy.com/p/9542.html

上一篇: 除了asp.net中的“〜/”路径之外,否认所有页面都是匿名的

下一篇: 使用WCF的MSMQ监听器