1

我有一个 WCF 服务,它连接到准备接收消息的服务总线队列。这很好,但如果我在处理消息时遇到问题,我希望能够将消息标记为死信。目前,如果我的代码引发异常,消息仍会从队列中删除,但我希望能够在配置中指定不从队列中删除,但将其标记为死信。我已经进行了一些搜索,但我无法弄清楚如何做到这一点。我目前正在将该服务作为 Windows 服务运行

Uri baseAddress = ServiceBusEnvironment.CreateServiceUri("sb", "namespace", "servicequeue"); _serviceHost = new ServiceHost(typeof(PaperlessImportServiceOneWay), baseAddress); _serviceHost.Open();

配置:

<services>
      <service name="Enrollment.ServiceOneWay">
        <endpoint name="ServiceOneWay"
                  address="sb://namespace.servicebus.windows.net/servicequeue"
                  binding="netMessagingBinding"
                  bindingConfiguration="messagingBinding"
                  contract="IServiceOneWaySoap"
                  behaviorConfiguration="sbTokenProvider" />
      </service>
</services>
      <netMessagingBinding>
        <binding name="messagingBinding" closeTimeout="00:03:00" openTimeout="00:03:00"
               receiveTimeout="00:03:00" sendTimeout="00:03:00" sessionIdleTimeout="00:01:00"
               prefetchCount="-1">
          <transportSettings batchFlushInterval="00:00:01" />
        </binding>
      </netMessagingBinding>

<behavior name="sbTokenProvider">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedSecret issuerName="owner" issuerSecret="XXXXXXXXXXXXXXXXXXXXXXXX" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
4

1 回答 1

1

In your interface for the opertion Contract add this [ReceiveContextEnabled(ManualControl = true)] then you can manage to commit or abandon the message Found it in this link: http://msdn.microsoft.com/en-us/library/windowsazure/hh532034.aspx

于 2013-02-15T18:15:40.907 回答