我正在使用netMsmqBinding和事務性隊列,雖然調用WCF服務時沒有問題,但該服務僅在處理完消息後60秒才拋出MsmqException。60秒後MsmqException(0xC00E0051)
這是例外:
System.ServiceModel.MsmqException(0xC00E0051):當從隊列中接收消息時發生錯誤:無法識別錯誤 -1072824239(0xc00e0051)。確保MSMQ已安裝並正在運行。確保隊列可以從中接收。在在 System.ServiceModel.Dispatcher.ErrorHandlingReceiver System.ServiceModel.Channels.MsmqInputChannelBase.TryReceive(時間跨度 超時,消息&消息)在 System.ServiceModel.Dispatcher.InputChannelBinder.TryReceive(時間跨度 超時,RequestContext的&的RequestContext)。 TryReceive(時間跨度 超時,RequestContext的&的RequestContext)
我做了一些研究,調試和跟蹤,我發現,在收到新郵件時,兩筆交易被打開,第一個承諾只是AFTE r服務執行,但第二個從不提交,那麼在60秒後,DTC終止它拋出MsmqException。 這是操作的定義:
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void SomeOperation(SomeParameter parameter)
{
// business logic
}
正在發生的事情的任何想法,我怎麼能解決這個問題呢?
UPDATE:
配置:
<netMsmqBinding>
<binding name="TransactionalMsmqBinding" exactlyOnce="true" deadLetterQueue="System" receiveErrorHandling="Move">
<security mode="None"/>
</binding>
</netMsmqBinding>
...
<service name="SomeNamespace.SomeService">
<endpoint contract="SomeNamespace.ISomeService" bindingConfiguration="TransactionalMsmqBinding" binding="netMsmqBinding" address="net.msmq://localhost/private/services/someservice.svc">
</endpoint>
<endpoint contract="SomeNamespace.IAnotherService" bindingConfiguration="TransactionalMsmqBinding" binding="netMsmqBinding" address="net.msmq://localhost/private/services/anotherservice.svc">
</endpoint>
</service>
服務實現:
[ExceptionShieldingBehavior(typeof(ArgumentValidationException), typeof(ValidationServiceException))]
[AuthorizationAndAuditBehaviour]
[ServiceBehavior(Namespace = GlobalConstants.ServiceContractNamespace)]
public class SomeService: ISomeService, IAnotherService
{
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void SomeOperation(SomeParameter parameter)
{
// business logic
}
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void AnotherOperation(AnotherParameter parameter)
{
// business logic
}
}
服務合同:
[ServiceContract(Namespace = GlobalConstants.ServiceContractNamespace)]
public interface ISomeService
{
[OperationContract(IsOneWay = true)]
void SomeOperation(SomeParameter parameter);
}
[ServiceContract(Namespace = GlobalConstants.ServiceContractNamespace)]
public interface IAnotherService
{
[OperationContract(IsOneWay = true)]
void AnotherOperation(AnotherParameter parameter);
}
完整的行爲:
- 客戶端發送一個消息
- 該服務被激活
- 的DTC啓動兩個交易(我可以看到他們在DTC監視器,並在TransactionManager.DistributedTransactionStarted事件)
- 操作完成後第一筆交易即告結束
- 第二筆交易在拋出後發生60秒後中止
- wcf主機(IIS)有時會出錯(我有一些代碼爲automatically recover it,顯然這種行爲已經改變了。網4)
- 如果主機被打破,自動恢復,都將再次下一條消息
- 如果主機也不會斷裂發生,第二個事務將不會啓動下一次,一切都將沒有問題的工作: )。
- 如果我回收程序池,這個問題再次啓動
你可以顯示:你的服務合同,服務配置和託管代碼? –
0xC00E0051。 MQ_ERROR_TRANSACTION_SEQUENCE。 「交易的操作順序不正確。」 DTC交易涉及什麼? –
嗨理查德和約翰,我已經添加了更多的細節,謝謝你的回答。 –