This topic has not yet been rated - Rate this topic

MsmqIntegrationBinding Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

The MsmqIntegrationBinding class maps Microsoft Message Queuing (MSMQ) messages to Windows Communication Foundation (WCF) messages.

System.Object
  System.ServiceModel.Channels.Binding
    System.ServiceModel.MsmqBindingBase
      System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding

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

public class MsmqIntegrationBinding : MsmqBindingBase

The MsmqIntegrationBinding type exposes the following members.

  Name Description
Public method MsmqIntegrationBinding() Initializes a new instance of the MsmqIntegrationBinding class.
Public method MsmqIntegrationBinding(MsmqIntegrationSecurityMode) Initializes a new instance of the MsmqIntegrationBinding class by using the specified MsmqIntegrationSecurityMode.
Public method MsmqIntegrationBinding(String) Initializes a new instance of the MsmqIntegrationBinding class from the settings of a specified configuration binding element.
Top
  Name Description
Public property CloseTimeout Gets or sets the interval of time provided for a connection to close before the transport raises an exception. (Inherited from Binding.)
Public property CustomDeadLetterQueue 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.)
Public property DeadLetterQueue Gets or sets an enumeration value that indicates the type of dead-letter queue to use. (Inherited from MsmqBindingBase.)
Public property Durable Gets or sets a value that indicates whether the messages processed by this binding are durable or volatile. (Inherited from MsmqBindingBase.)
Public property ExactlyOnce Gets or sets a value that indicates whether messages processed by this binding are received exactly once. (Inherited from MsmqBindingBase.)
Public property MaxReceivedMessageSize Gets or sets the maximum size, in bytes, for a message that is processed by this binding. (Inherited from MsmqBindingBase.)
Public property MaxRetryCycles Gets or sets the maximum number of retry cycles to attempt delivery of messages to the receiving application. (Inherited from MsmqBindingBase.)
Public property MessageVersion Gets the message version used by clients and services configured with the binding. (Inherited from Binding.)
Public property Name Gets or sets the name of the binding. (Inherited from Binding.)
Public property Namespace Gets or sets the XML namespace of the binding. (Inherited from Binding.)
Public property OpenTimeout Gets or sets the interval of time provided for a connection to open before the transport raises an exception. (Inherited from Binding.)
Public property ReceiveContextEnabled Gets or sets a value that indicates whether the receive context behavior is requested. (Inherited from MsmqBindingBase.)
Public property ReceiveErrorHandling Gets or sets an enumeration value that specifies how poison messages are handled. (Inherited from MsmqBindingBase.)
Public property ReceiveRetryCount Gets or sets the maximum number of immediate delivery attempts on a message that is read from the application queue. (Inherited from MsmqBindingBase.)
Public property ReceiveTimeout 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.)
Public property RetryCycleDelay 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.)
Public property Scheme Returns the scheme for this binding. (Inherited from MsmqBindingBase.)
Public property Security Gets the MsmqIntegrationSecurity that is associated with this binding.
Public property SendTimeout Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception. (Inherited from Binding.)
Public property SerializationFormat Gets or sets the serialization format to be used to serialize or deserialize the message.
Public property TimeToLive 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.)
Public property UseMsmqTracing Gets or sets a value that indicates whether messages processed by this binding should be traced. (Inherited from MsmqBindingBase.)
Public property UseSourceJournal 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.)
Public property ValidityDuration Gets or sets a value that specifies the duration a message will be locked by the receive context feature. (Inherited from MsmqBindingBase.)
Top
  Name Description
Public method BuildChannelFactory<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.)
Public method BuildChannelFactory<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method BuildChannelListener<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.)
Public method CanBuildChannelFactory<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.)
Public method CanBuildChannelFactory<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.)
Public method CanBuildChannelListener<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.)
Public method CanBuildChannelListener<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.)
Public method CreateBindingElements Returns the binding elements in the basic profile stack. (Overrides Binding.CreateBindingElements().)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetProperty<T> Returns a typed object requested, if present, from the appropriate layer in the binding stack. (Inherited from Binding.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ShouldSerializeName Returns whether the name of the binding should be serialized. (Inherited from Binding.)
Public method ShouldSerializeNamespace Returns whether the namespace of the binding should be serialized. (Inherited from Binding.)
Public method ShouldSerializeSecurity Gets a value that specifies whether security information should be serialized.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Explicit interface implemetation Private property IBindingRuntimePreferences.ReceiveSynchronously Gets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously. (Inherited from MsmqBindingBase.)
Top

This binding can be used to enable WCF applications to send and receive messages to and from existing MSMQ applications that use COM, native C++ APIs or the types defined in the System.Messaging namespace.

The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the client:

The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the service:


[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
[ServiceKnownType(typeof(PurchaseOrder))]
public interface IOrderProcessor
{
    [OperationContract(IsOneWay = true, Action = "*")]
    void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> msg);
}


The following code illustrates how to use the MsmqIntegrationBinding binding on the service programmatically:


    public class OrderProcessorService : IOrderProcessor
    {
        [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
        public void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> ordermsg)
        {
            PurchaseOrder po = (PurchaseOrder)ordermsg.Body;
            Random statusIndexer = new Random();
            po.Status = (OrderStates)statusIndexer.Next(3);
            Console.WriteLine("Processing {0} ", po);
        }

	    // Host the service within this EXE console application.
	public static void Main()
	{
	    // Get base address from appsettings in configuration.
		Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]);

	    // Create a ServiceHost for the CalculatorService type and provide the base address.
		using (ServiceHost serviceHost = new ServiceHost(typeof(IOrderProcessor), 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("The service is running in the following account: {0}", WindowsIdentity.GetCurrent().Name);
			Console.WriteLine("Press <ENTER> to terminate service.");
			Console.WriteLine();
			Console.ReadLine();

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

    }


The following code illustrates how to use the MsmqIntegrationBinding binding on the client programmatically:


MsmqIntegrationBinding binding = new MsmqIntegrationBinding();
EndpointAddress address = new EndpointAddress("msmq.formatname:DIRECT=OS:.\\private$\\Orders");
ChannelFactory<IOrderProcessor> channelFactory = new ChannelFactory<IOrderProcessor>(binding, address);
IOrderProcessor channel = channelFactory.CreateChannel();

PurchaseOrder po = new PurchaseOrder();
po.customerId = "somecustomer.com";
po.poNumber = Guid.NewGuid().ToString();

PurchaseOrderLineItem lineItem1 = new PurchaseOrderLineItem();
lineItem1.productId = "Blue Widget";
lineItem1.quantity = 54;
lineItem1.unitCost = 29.99F;

PurchaseOrderLineItem lineItem2 = new PurchaseOrderLineItem();
lineItem2.productId = "Red Widget";
lineItem2.quantity = 890;
lineItem2.unitCost = 45.89F;

po.orderLineItems = new PurchaseOrderLineItem[2];
po.orderLineItems[0] = lineItem1;
po.orderLineItems[1] = lineItem2;


MsmqMessage<PurchaseOrder> ordermsg = new MsmqMessage<PurchaseOrder>(po);
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
    channel.SubmitPurchaseOrder(ordermsg);
    scope.Complete();
}
Console.WriteLine("Order has been submitted:{0}", po);


.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)