Inside the Standard Bindings: NetMsmq

Index for bindings in this series:

It's been a while since the last article in the series on standard bindings, but there are only two left to go so I wanted to finish the series off. These last two bindings are a bit different than the others due to their specialization. Today is the standard binding for MSMQ and tomorrow is the standard binding for PeerChannel.

Microsoft Message Queuing (MSMQ) is a durable queue service that comes with Windows. MSMQ is the only transport included by default in WCF that is durable and that has asynchronous delivery of messages. You'll need to install message queuing support to actually operate your own queue, although you can create an instance of the binding even if the components are not present.

Standard binding standard disclaimer:

I've cut down on the number of properties presented by eliminating duplicates between the binding settings and binding element settings. For instance, the XML reader quotas can be set on either the binding or the message encoder binding element, but I'm only going to show them on the message encoder. I've also omitted most of the security credential settings because they're very messy and you hopefully won't need to change them much.

MSMQ supports both transport and message security and has the additional capability of being able to turn both on at the same time. I'll start though by showing what the binding looks like with security disabled.

  1. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

     MaxReadPoolSize: 64
    MaxSessionSize: 2048
    MaxWritePoolSize: 16
    ReaderQuotas: 
      MaxArrayLength: 16384
      MaxBytesPerRead: 4096
      MaxDepth: 32
      MaxNameTableCharCount: 16384
      MaxStringContentLength: 8192
    
  2. System.ServiceModel.Channels.MsmqTransportBindingElement

     CustomDeadLetterQueue: 
    DeadLetterQueue: System
    Durable: True
    ExactlyOnce: True
    ManualAddressing: False
    MaxBufferPoolSize: 524288
    MaxPoolSize: 8
    MaxReceivedMessageSize: 65536
    MaxRetryCycles: 2
    MsmqTransportSecurity: 
      MsmqAuthenticationMode: None
      MsmqEncryptionAlgorithm: RC4Stream
      MsmqProtectionLevel: None
      MsmqSecureHashAlgorithm: Sha1
    QueueTransferProtocol: Native
    ReceiveErrorHandling: Fault
    ReceiveRetryCount: 5
    RetryCycleDelay: 00:30:00
    Scheme: net.msmq
    TimeToLive: 1.00:00:00
    TransactedReceiveEnabled: True
    UseActiveDirectory: False
    UseMsmqTracing: False
    UseSourceJournal: False
    

This binding contains very few entries and all of the queuing configuration settings are available directly off of the transport binding element. There are no additional settings provided at the binding level besides the typical ones you see on all bindings.

 CloseTimeout: 00:01:00
EnvelopeVersion: Soap12 (https://www.w3.org/2003/05/soap-envelope)
Namespace: https://tempuri.org/
OpenTimeout: 00:01:00
ReceiveTimeout: 00:10:00
SendTimeout: 00:01:00

The MSMQ transport channel provides transport-level security itself so there is no change to the channel stack when transport security is enabled.

  1. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
  2. System.ServiceModel.Channels.MsmqTransportBindingElement

Adding message security does put a new element in the channel stack, but since there's no change when transport security is enabled, the channel stack looks the same whether the security mode is Message or Both.

  1. System.ServiceModel.Channels.SymmetricSecurityBindingElement
  2. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
  3. System.ServiceModel.Channels.MsmqTransportBindingElement

Next time: Inside the Standard Bindings: NetPeerTcp