在 C# 中使用事务性 MSMQ 和 WCF
有时由于某种原因,消息会从 MSMQ 重新分派,即使上一次消息已成功处理(即没有未处理的异常或任何事情)。只有 1 个我放入队列的消息。
任何想法为什么?
当然,当 msg 被调度时,我也在调试,但我在某些区域只有很少的断点,并且在 msg 流入的上下文中,我花费不超过 3 秒的时间查看我需要查看的内容系统。
任何想法为什么重复调度?
更新:代码:
[ServiceContract]
[ServiceKnownType(typeof(CustomMessage))]
[ServiceKnownType(typeof(MessageA))]
[ServiceKnownType(typeof(MessageB))]
public interface IMessageHandlerService
{
[OperationContract(IsOneWay = true, Action = "*")]
void ProcessMessage(MsmqMessage<CustomMessage> message);
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single, ReleaseServiceInstanceOnTransactionComplete = false)]
public sealed class MessageHandlerService : IMessageHandlerService
{
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void ProcessMessage(MsmqMessage<CustomMessage> message)
{
...
}
}
我的ABC:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="IncludeExceptionDetails">
<callbackDebug includeExceptionDetailInFaults="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Services.Implementation.MessageHandler.MessageHandlerService">
<endpoint address="msmq.formatname:DIRECT=OS:.\private$\msgs" binding="msmqIntegrationBinding" bindingConfiguration="MessageHandlerBinding" contract="Services.Contracts.Messages.IMessageHandlerService">
</endpoint>
</service>
</services>
<bindings>
<msmqIntegrationBinding>
<binding name="MessageHandlerBinding"
closeTimeout="00:30:00"
receiveTimeout="01:00:00"
retryCycleDelay="00:00:10"
receiveRetryCount="0"
exactlyOnce="true"
maxRetryCycles="1"
receiveErrorHandling="Move">
<security mode="None"/>
</binding>
</msmqIntegrationBinding>
</bindings>
</system.serviceModel>
我真的不明白这个问题是如何含糊不清的:-) 它很简单。当 wcf 绑定到 msmq 时,有时即使第一条消息已成功处理,同一条消息也会被分派两次。
你还需要什么其他细节?请告诉!