简体   繁体   中英

How do I use MsmqIntegrationBinding with a non-transactional queue?

This is my service contract:

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

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

End Interface

This is my class

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

When I try to open the port with this code I get an error

    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 occurred Message="The operation 'ValidateCusipInMessage' on contract 'ISecurityMasterChanged' is configured with TransactionAutoComplete set to true and with TransactionScopeRequired set to false. TransactionAutoComplete requires that TransactionScopeRequired is set to true." Source="System.ServiceModel"

This doesn't make sense to me because, as you can see, TransactionAutoComplete is not set to true.

The default for TransactionAutoComplete is true. Which makes me wonder if you have to decorate your contract with this attribute instead of your class?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM