azure - 服务总线队列主机服务的异常处理

标签 azure azureservicebus

我有一个连接到服务总线队列的 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>

最佳答案

在您的合约操作界面中添加此内容 [ReceiveContextEnabled(手动控制 = true)] 然后你可以设法提交或放弃该消息 在此链接中找到它: http://msdn.microsoft.com/en-us/library/windowsazure/hh532034.aspx

关于azure - 服务总线队列主机服务的异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14863368/

相关文章:

python-3.x - python SDK 上的 Azure Webjobs

sql - dbcontext.savechanges 始终保存默认值

azure - Windows Azure - 自动负载平衡 - 分区

azure - 在 Azure 上解析 - 我收到 "Error: Unauthorized"

Azure 性能计数器和扩展策略?

c# - 如何取消 Azure 主题中的预定消息

azureservicebus - 如何使用特定的 ServiceInsight 从死信队列重新发送消息?

c# - 如果我的上下文已释放,在收到来自 Azure 服务总线监听器/使用者的消息后如何使用 EF Core?

c# - 在 Azure Function 中将 BrokeredMessage 与 ServiceBus 队列触发器结合使用

c# - 找不到有效的帐户信息组合