如何将MsmqIntegrationBinding与非事务性队列一起使用?

时间:2009-11-04 16:06:08

标签: wcf msmq msmqintegrationbinding

这是我的服务合同:

<ServiceContract> _
<ServiceKnownType(GetType(String))> _
Public Interface ISecurityMasterChanged

<OperationContract(IsOneWay:=True, Action:="*")> _
Sub ValidateCusipInMessage(ByVal message As MsmqMessage(Of String))

End Interface

这是我的班级

Public Class SecurityValidator
    Implements ISecurityMasterChanged

<OperationBehavior(TransactionAutoComplete:=False, TransactionScopeRequired:=False)> _
<ServiceKnownType(GetType(String))> _
Public Sub ValidateCusipInMessage(ByVal message As MsmqIntegration.MsmqMessage(Of String)) Implements ISecurityMasterChanged.ValidateCusipInMessage
'...
End Sub

当我尝试使用此代码打开端口时出现错误

    m_ServiceHostQueue = New ServiceHost(Me)
    m_ServiceHostQueue.AddServiceEndpoint(GetType(ISecurityMasterChanged), New MsmqIntegrationBinding With {.ExactlyOnce = False}, m_Config("SMChanged Queue").ToString)
    m_ServiceHostQueue.Open()

发生了System.InvalidOperationException   Message =“合同'ISecurityMasterChanged'上的操作'ValidateCusipInMessage'配置为TransactionAutoComplete设置为true并且TransactionScopeRequired设置为false.TransactionAutoComplete要求TransactionScopeRequired设置为true。”   源= “System.ServiceModel”

这对我没有意义,因为正如您所看到的,TransactionAutoComplete未设置为true。

1 个答案:

答案 0 :(得分:0)

TransactionAutoComplete的默认值为true。这让我想知道你是否必须用这个属性而不是你的类来装饰你的合同?