gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 03:19:21 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com