简体   繁体   中英

How to implement IIS-based dead-letter service when using MsmqIntegrationBinding

So, I was able to get my dead-letter service pulling from the queue when using NetMsmqBinding. However, when I switched to using MsmqIntegrationBinding to push messages to the target queue, the dead-letter queue no longer sends to the dead-letter service. The messages are no longer WCF-formatted - they are just XML serialized. I'm not sure how to get the piping setup to send to the new service. The queue and URL still match.

I've tried running as it was (with netMsmqBinding), switching to msmqIntegrationBinding, and specifying the serializationFormat as below:

<bindings>
  <msmqIntegrationBinding>
    <binding exactlyOnce="true" durable="true" serializationFormat="Xml">
      <security mode="Transport" />
    </binding>
  </msmqIntegrationBinding>
</bindings>

However, none of this seems to work. Any ideas would be welcome.

After enabling WCF tracing (with switchValue="All" ), I was able to see that I was getting the following Exception:

An error occurred while deserializing an MSMQ message's XML body. The message cannot be received. Ensure that the service contract is decorated with appropriate [ServiceKnownType] attributes or the TargetSerializationTypes property is set on the MsmqIntegrationBindingElement.

After finding the right contract to which to add ServiceKnownType for each of my Types, I encountered this further Exception:

The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

From Simon Evans' Blog , we find the following information:

MsmqIntegrationBinding requires contracts that are designed only for its use. Unless additional behaviors are applied to the dispatcher, the service contract can contain only one service operation.

Basically, as we've seen in the MSDN example , using MsmqIntegrationBinding requires one operation that accepts all messages ( Action = "*" [or, really, Action = "" would probably work as well]). Once I switched to msmqIntegrationBinding and switched my contract (ensuring I still had ServiceKnownType on the new one), everything started working.

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