NetMsmqBinding Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Represents a queued binding that is suitable for cross-machine communication.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

System.Object
  System.ServiceModel.Channels.Binding
    System.ServiceModel.MsmqBindingBase
      System.ServiceModel.NetMsmqBinding

public class NetMsmqBinding : MsmqBindingBase

NameDescription
System_CAPS_pubmethodNetMsmqBinding()

Initializes a new instance of the NetMsmqBinding class.

System_CAPS_pubmethodNetMsmqBinding(NetMsmqSecurityMode)

Initializes a new instance of the NetMsmqBinding class using the specified security mode.

System_CAPS_pubmethodNetMsmqBinding(String)

Initializes a new instance of the NetMsmqBinding class from the settings of a specified configuration binding element.

NameDescription
System_CAPS_pubpropertyCloseTimeout

Gets or sets the interval of time provided for a connection to close before the transport raises an exception.(Inherited from Binding.)

System_CAPS_pubpropertyCustomDeadLetterQueue

Gets or sets a URI that contains the location of the dead-letter queue for each application, where messages that have expired or that have failed transfer or delivery are placed.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyDeadLetterQueue

Gets or sets an enumeration value that indicates the type of dead-letter queue to use.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyDurable

Gets or sets a value that indicates whether the messages processed by this binding are durable or volatile.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyEnvelopeVersion

Gets the version of SOAP that is used for messages processed by this binding.

System_CAPS_pubpropertyExactlyOnce

Gets or sets a value that indicates whether messages processed by this binding are received exactly once.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyMaxBufferPoolSize

Gets or sets the maximum amount of memory that is allocated for use by the message buffer manager that receives messages from the channel.

System_CAPS_pubpropertyMaxReceivedMessageSize

Gets or sets the maximum size, in bytes, for a message that is processed by this binding.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyMaxRetryCycles

Gets or sets the maximum number of retry cycles to attempt delivery of messages to the receiving application.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyMessageVersion

Gets the message version used by clients and services configured with the binding.(Inherited from Binding.)

System_CAPS_pubpropertyName

Gets or sets the name of the binding.(Inherited from Binding.)

System_CAPS_pubpropertyNamespace

Gets or sets the XML namespace of the binding.(Inherited from Binding.)

System_CAPS_pubpropertyOpenTimeout

Gets or sets the interval of time provided for a connection to open before the transport raises an exception.(Inherited from Binding.)

System_CAPS_pubpropertyQueueTransferProtocol

Gets or sets an enumeration value that indicates the queued communication channel transport that this binding uses.

System_CAPS_pubpropertyReaderQuotas

Gets or sets the XmlDictionaryReaderQuotas that is associated with this binding.

System_CAPS_pubpropertyReceiveContextEnabled

Gets or sets a value that indicates whether the receive context behavior is requested.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyReceiveErrorHandling

Gets or sets an enumeration value that specifies how poison messages are handled.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyReceiveRetryCount

Gets or sets the maximum number of immediate delivery attempts on a message that is read from the application queue.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyReceiveTimeout

Gets or sets the interval of time that a connection can remain inactive, during which no application messages are received, before it is dropped.(Inherited from Binding.)

System_CAPS_pubpropertyRetryCycleDelay

Gets or sets a value that indicates the time delay between retry cycles when attempting to deliver a message that cannot be delivered immediately.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyScheme

Returns the scheme for this binding.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertySecurity

Gets or sets the NetMsmqSecurity that is associated with this binding.

System_CAPS_pubpropertySendTimeout

Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception.(Inherited from Binding.)

System_CAPS_pubpropertyTimeToLive

Gets or sets the interval of time that indicates how long the messages processed by this binding can be in the queue before they expire.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyUseActiveDirectory

Gets or sets a value that indicates whether queue addresses should be converted using Active Directory.

System_CAPS_pubpropertyUseMsmqTracing

Gets or sets a value that indicates whether messages processed by this binding should be traced.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyUseSourceJournal

Gets or sets a value that indicates whether copies of messages processed by this binding should be stored in the source journal queue.(Inherited from MsmqBindingBase.)

System_CAPS_pubpropertyValidityDuration

Gets or sets a value that specifies the duration a message will be locked by the receive context feature.(Inherited from MsmqBindingBase.)

NameDescription
System_CAPS_pubmethodBuildChannelFactory<TChannel>(BindingParameterCollection)

Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by a collection of binding parameters.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelFactory<TChannel>(Object[])

Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by an object array.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(BindingParameterCollection)

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified by a collection of binding parameters.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Object[])

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, BindingParameterCollection)

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, Object[])

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, BindingParameterCollection)

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection)

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[])

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, Object[])

Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(BindingParameterCollection)

Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the collection of binding parameters specified.(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(Object[])

Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the requirements specified by an object array.(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(BindingParameterCollection)

Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the collection of binding parameters specified.(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(Object[])

Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the criteria specified in an array of objects.(Inherited from Binding.)

System_CAPS_pubmethodCreateBindingElements()

Returns an ordered collection of binding elements contained in the current binding.(Overrides Binding.CreateBindingElements().)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetProperty<T>(BindingParameterCollection)

Returns a typed object requested, if present, from the appropriate layer in the binding stack.(Inherited from Binding.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodShouldSerializeName()

Returns whether the name of the binding should be serialized.(Inherited from Binding.)

System_CAPS_pubmethodShouldSerializeNamespace()

Returns whether the namespace of the binding should be serialized.(Inherited from Binding.)

System_CAPS_pubmethodShouldSerializeReaderQuotas()

Returns a value that indicates whether the ReaderQuotas property has changed from its default value and should be serialized.

System_CAPS_pubmethodShouldSerializeSecurity()

Returns a value that indicates whether the Security property has changed from its default value and should be serialized.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privpropertyIBindingRuntimePreferences.ReceiveSynchronously

Gets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously.(Inherited from MsmqBindingBase.)

The NetMsmqBinding binding provides support for queuing by using Message Queuing (MSMQ) as a transport and enables support for loosely-coupled applications, failure isolation, load leveling and disconnected operations. For a discussion of these features, see Queues Overview.

This is one of the system-provided bindings provided by Windows Communication Foundation (WCF). The recommended procedure is to define the binding using configuration values and not to use a code-based approach, except in certain advanced scenarios where configuration values must be set as a service is initialized.

The following example shows how to configure a service to use the NetMsmqBinding binding.

First, the configuration file.

Next, the actual service code.

// Define a service contract. 
[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")]
public interface IQueueCalculator
{
    [OperationContract(IsOneWay=true)]
    void Add(double n1, double n2);
    [OperationContract(IsOneWay = true)]
    void Subtract(double n1, double n2);
    [OperationContract(IsOneWay = true)]
    void Multiply(double n1, double n2);
    [OperationContract(IsOneWay = true)]
    void Divide(double n1, double n2);
}
// Service class that implements the service contract.
// Added code to write output to the console window
public class CalculatorService : IQueueCalculator
{
    [OperationBehavior]
    public void Add(double n1, double n2)
    {
        double result = n1 + n2;
        Console.WriteLine("Received Add({0},{1}) - result: {2}", n1, n2, result);
    }

    [OperationBehavior]
    public void Subtract(double n1, double n2)
    {
        double result = n1 - n2;
        Console.WriteLine("Received Subtract({0},{1}) - result: {2}", n1, n2, result);
    }

    [OperationBehavior]
    public void Multiply(double n1, double n2)
    {
        double result = n1 * n2;
        Console.WriteLine("Received Multiply({0},{1}) - result: {2}", n1, n2, result);
    }

    [OperationBehavior]
    public void Divide(double n1, double n2)
    {
        double result = n1 / n2;
        Console.WriteLine("Received Divide({0},{1}) - result: {2}", n1, n2, result);
    }
}
// This is the hosting application. This code can appear directly in the service class as well.
class HostApp
{
    // Host the service within this EXE console application.
    public static void Main()
    {
        // Get MSMQ queue name from appsettings in configuration.
        string queueName = ConfigurationManager.AppSettings["queueName"];

        // Create the transacted MSMQ queue if necessary.
        if (!MessageQueue.Exists(queueName))
            MessageQueue.Create(queueName, true);

        // Get the base address that is used to listen for WS-MetaDataExchange requests.
        // This is useful to generate a proxy for the client.
        string baseAddress = ConfigurationManager.AppSettings["baseAddress"];

        // Create a ServiceHost for the CalculatorService type.
        using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), new Uri(baseAddress)))
        {
            // Open the ServiceHostBase to create listeners and start listening for messages.
            serviceHost.Open();

            // The service can now be accessed.
            Console.WriteLine("The service is ready.");
            Console.WriteLine("Press <ENTER> to terminate service.");
            Console.WriteLine();
            Console.ReadLine();

            // Close the ServiceHostBase to shutdown the service.
            serviceHost.Close();
        }
    }
}

.NET Framework
Available since 3.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: