MsmqIntegrationBinding MsmqIntegrationBinding MsmqIntegrationBinding MsmqIntegrationBinding Class

定义

MsmqIntegrationBinding 类,将 Microsoft 消息队列 (MSMQ) 消息映射到 Windows Communication Foundation (WCF) 消息。The MsmqIntegrationBinding class maps Microsoft Message Queuing (MSMQ) messages to Windows Communication Foundation (WCF) messages.

public ref class MsmqIntegrationBinding : System::ServiceModel::MsmqBindingBase
public class MsmqIntegrationBinding : System.ServiceModel.MsmqBindingBase
type MsmqIntegrationBinding = class
    inherit MsmqBindingBase
Public Class MsmqIntegrationBinding
Inherits MsmqBindingBase
继承
MsmqIntegrationBindingMsmqIntegrationBindingMsmqIntegrationBindingMsmqIntegrationBinding

示例

下面的配置文件片段演示如何在客户端上配置 MsmqIntegrationBinding 绑定:The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the client:

下面的配置文件片段演示如何在服务上配置 MsmqIntegrationBinding 绑定: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);
}
<ServiceContract(Namespace:="http:'Microsoft.ServiceModel.Samples")> _
<ServiceKnownType(GetType(PurchaseOrder))> _
Public Interface IOrderProcessor
    <OperationContract(IsOneWay:=True, Action:="*")> _
    Sub SubmitPurchaseOrder(ByVal msg As MsmqMessage(Of PurchaseOrder))
End Interface

下面的代码演示如何以编程方式在服务上使用 MsmqIntegrationBinding 绑定: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();
	}
}

   }
Public Class OrderProcessorService
    Implements IOrderProcessor

    <OperationBehavior(TransactionScopeRequired:=True, TransactionAutoComplete:=True)> _
    Public Sub SubmitPurchaseOrder(ByVal ordermsg As MsmqMessage(Of PurchaseOrder)) Implements IOrderProcessor.SubmitPurchaseOrder
        Dim po As PurchaseOrder = ordermsg.Body
        Dim statusIndexer As New Random()
        po.Status = statusIndexer.Next(3)
        Console.WriteLine("Processing {0} ", po)
    End Sub
End Class

下面的代码演示如何以编程方式在客户端上使用 MsmqIntegrationBinding 绑定: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);
Dim binding As New MsmqIntegrationBinding()
Dim address As New EndpointAddress("msmq.formatname:DIRECT=OS:.\\private$\\Orders")
Dim channelFactory As New ChannelFactory(Of IOrderProcessor)(binding, address)
Dim channel As IOrderProcessor = channelFactory.CreateChannel()

Dim po As New PurchaseOrder()
po.customerId = "somecustomer.com"
po.poNumber = Guid.NewGuid().ToString()

Dim lineItem1 As New PurchaseOrderLineItem()
lineItem1.productId = "Blue Widget"
lineItem1.quantity = 54
lineItem1.unitCost = 29.99F

Dim lineItem2 = New PurchaseOrderLineItem()
lineItem2.productId = "Red Widget"
lineItem2.quantity = 890
lineItem2.unitCost = 45.89F

Dim lineItems(2) As PurchaseOrderLineItem
lineItems(0) = lineItem1
lineItems(1) = lineItem2

po.orderLineItems = lineItems

Dim ordermsg As MsmqMessage(Of PurchaseOrder) = New MsmqMessage(Of PurchaseOrder)(po)
Using scope As New TransactionScope(TransactionScopeOption.Required)
    channel.SubmitPurchaseOrder(ordermsg)
    scope.Complete()
End Using
Console.WriteLine("Order has been submitted:{0}", po)

注解

重要

使用不受信任的数据调用此类中的方法存在安全风险。Calling methods from this class with untrusted data is a security risk. 仅使用受信任的数据调用此类中的方法。Call the methods from this class only with trusted data. 有关详细信息,请参阅数据验证For more information, see Data Validation.

此绑定可用于使 WCF 应用程序能够发送和接收的消息和从现有 MSMQ 应用程序使用 COM、 本机 c + + Api 或类型的定义中System.Messaging命名空间。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.

构造函数

MsmqIntegrationBinding() MsmqIntegrationBinding() MsmqIntegrationBinding() MsmqIntegrationBinding()

初始化 MsmqIntegrationBinding 类的新实例。Initializes a new instance of the MsmqIntegrationBinding class.

MsmqIntegrationBinding(MsmqIntegrationSecurityMode) MsmqIntegrationBinding(MsmqIntegrationSecurityMode) MsmqIntegrationBinding(MsmqIntegrationSecurityMode) MsmqIntegrationBinding(MsmqIntegrationSecurityMode)

使用指定的 MsmqIntegrationBinding 初始化 MsmqIntegrationSecurityMode 类的新实例。Initializes a new instance of the MsmqIntegrationBinding class by using the specified MsmqIntegrationSecurityMode.

MsmqIntegrationBinding(String) MsmqIntegrationBinding(String) MsmqIntegrationBinding(String) MsmqIntegrationBinding(String)

从指定配置绑定元素的设置中初始化 MsmqIntegrationBinding 类的新实例。Initializes a new instance of the MsmqIntegrationBinding class from the settings of a specified configuration binding element.

属性

CloseTimeout CloseTimeout CloseTimeout CloseTimeout

获取或设置在传输引发异常之前可用于关闭连接的时间间隔。Gets or sets the interval of time provided for a connection to close before the transport raises an exception.

(Inherited from Binding)
CustomDeadLetterQueue CustomDeadLetterQueue CustomDeadLetterQueue CustomDeadLetterQueue

获取或设置一个 URI,该 URI 包含每个应用程序的死信队列(该队列用于放置已过期的消息以及传输或传递失败的消息)的位置。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)
DeadLetterQueue DeadLetterQueue DeadLetterQueue DeadLetterQueue

获取或设置一个枚举值,该值指示要使用的死信队列的类型。Gets or sets an enumeration value that indicates the type of dead-letter queue to use.

(Inherited from MsmqBindingBase)
Durable Durable Durable Durable

获取或设置一个值,该值指定此绑定处理的消息是持久的还是可变的。Gets or sets a value that indicates whether the messages processed by this binding are durable or volatile.

(Inherited from MsmqBindingBase)
ExactlyOnce ExactlyOnce ExactlyOnce ExactlyOnce

获取或设置一个值,该值指示是否只接收一次由此绑定处理的消息。Gets or sets a value that indicates whether messages processed by this binding are received exactly once.

(Inherited from MsmqBindingBase)
IBindingRuntimePreferences.ReceiveSynchronously IBindingRuntimePreferences.ReceiveSynchronously IBindingRuntimePreferences.ReceiveSynchronously IBindingRuntimePreferences.ReceiveSynchronously

获取一个值,该值指示传入请求是由同步处理更加有效还是异步处理更加有效。Gets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously.

(Inherited from MsmqBindingBase)
MaxReceivedMessageSize MaxReceivedMessageSize MaxReceivedMessageSize MaxReceivedMessageSize

获取或设置此绑定可处理消息的最大字节大小。Gets or sets the maximum size, in bytes, for a message that is processed by this binding.

(Inherited from MsmqBindingBase)
MaxRetryCycles MaxRetryCycles MaxRetryCycles MaxRetryCycles

获取或设置尝试向接收应用程序传递消息的最大重试周期数。Gets or sets the maximum number of retry cycles to attempt delivery of messages to the receiving application.

(Inherited from MsmqBindingBase)
MessageVersion MessageVersion MessageVersion MessageVersion

获取由绑定所配置的客户端和服务使用的消息版本。Gets the message version used by clients and services configured with the binding.

(Inherited from Binding)
Name Name Name Name

获取或设置绑定的名称。Gets or sets the name of the binding.

(Inherited from Binding)
Namespace Namespace Namespace Namespace

获取或设置绑定的 XML 命名空间。Gets or sets the XML namespace of the binding.

(Inherited from Binding)
OpenTimeout OpenTimeout OpenTimeout OpenTimeout

获取或设置在传输引发异常之前可用于打开连接的时间间隔。Gets or sets the interval of time provided for a connection to open before the transport raises an exception.

(Inherited from Binding)
ReceiveContextEnabled ReceiveContextEnabled ReceiveContextEnabled ReceiveContextEnabled

获取或设置一个指示是否请求接收上下文行为的值。Gets or sets a value that indicates whether the receive context behavior is requested.

(Inherited from MsmqBindingBase)
ReceiveErrorHandling ReceiveErrorHandling ReceiveErrorHandling ReceiveErrorHandling

获取或设置一个枚举值,该值指定如何处理病毒消息。Gets or sets an enumeration value that specifies how poison messages are handled.

(Inherited from MsmqBindingBase)
ReceiveRetryCount ReceiveRetryCount ReceiveRetryCount ReceiveRetryCount

获取或设置从应用程序队列读取的消息的最大立即传递尝试次数。Gets or sets the maximum number of immediate delivery attempts on a message that is read from the application queue.

(Inherited from MsmqBindingBase)
ReceiveTimeout ReceiveTimeout ReceiveTimeout 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)
RetryCycleDelay RetryCycleDelay RetryCycleDelay 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)
Scheme Scheme Scheme Scheme

返回此绑定的方案。Returns the scheme for this binding.

(Inherited from MsmqBindingBase)
Security Security Security Security

获取与此绑定相关联的 MsmqIntegrationSecurityGets the MsmqIntegrationSecurity that is associated with this binding.

SendTimeout SendTimeout SendTimeout SendTimeout

获取或设置在传输引发异常之前可用于完成写入操作的时间间隔。Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception.

(Inherited from Binding)
SerializationFormat SerializationFormat SerializationFormat SerializationFormat

获取或设置要用于序列化或反序列化消息的序列化格式。Gets or sets the serialization format to be used to serialize or deserialize the message.

TimeToLive TimeToLive TimeToLive 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)
UseMsmqTracing UseMsmqTracing UseMsmqTracing UseMsmqTracing

获取或设置一个值,该值指示是否应跟踪由此绑定处理的消息。Gets or sets a value that indicates whether messages processed by this binding should be traced.

(Inherited from MsmqBindingBase)
UseSourceJournal UseSourceJournal UseSourceJournal 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)
ValidityDuration ValidityDuration ValidityDuration ValidityDuration

获取或设置一个值,该值指定由接收上下文功能锁定消息的持续时间。Gets or sets a value that specifies the duration a message will be locked by the receive context feature.

(Inherited from MsmqBindingBase)

方法

BuildChannelFactory<TChannel>(BindingParameterCollection) BuildChannelFactory<TChannel>(BindingParameterCollection) BuildChannelFactory<TChannel>(BindingParameterCollection) 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)
BuildChannelFactory<TChannel>(Object[]) BuildChannelFactory<TChannel>(Object[]) BuildChannelFactory<TChannel>(Object[]) 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)
BuildChannelListener<TChannel>(BindingParameterCollection) BuildChannelListener<TChannel>(BindingParameterCollection) BuildChannelListener<TChannel>(BindingParameterCollection) 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)
BuildChannelListener<TChannel>(Object[]) BuildChannelListener<TChannel>(Object[]) BuildChannelListener<TChannel>(Object[]) 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)
BuildChannelListener<TChannel>(Uri, BindingParameterCollection) BuildChannelListener<TChannel>(Uri, BindingParameterCollection) BuildChannelListener<TChannel>(Uri, BindingParameterCollection) 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)
BuildChannelListener<TChannel>(Uri, Object[]) BuildChannelListener<TChannel>(Uri, Object[]) BuildChannelListener<TChannel>(Uri, Object[]) 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)
BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection) BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection) BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection) 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)
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection) BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection) BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection) 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)
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[]) BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[]) BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[]) 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)
BuildChannelListener<TChannel>(Uri, String, Object[]) BuildChannelListener<TChannel>(Uri, String, Object[]) BuildChannelListener<TChannel>(Uri, String, Object[]) 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)
CanBuildChannelFactory<TChannel>(BindingParameterCollection) CanBuildChannelFactory<TChannel>(BindingParameterCollection) CanBuildChannelFactory<TChannel>(BindingParameterCollection) 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)
CanBuildChannelFactory<TChannel>(Object[]) CanBuildChannelFactory<TChannel>(Object[]) CanBuildChannelFactory<TChannel>(Object[]) 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)
CanBuildChannelListener<TChannel>(BindingParameterCollection) CanBuildChannelListener<TChannel>(BindingParameterCollection) CanBuildChannelListener<TChannel>(BindingParameterCollection) 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)
CanBuildChannelListener<TChannel>(Object[]) CanBuildChannelListener<TChannel>(Object[]) CanBuildChannelListener<TChannel>(Object[]) 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)
CreateBindingElements() CreateBindingElements() CreateBindingElements() CreateBindingElements()

返回基本配置文件堆栈中的绑定元素。Returns the binding elements in the basic profile stack.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetProperty<T>(BindingParameterCollection) GetProperty<T>(BindingParameterCollection) GetProperty<T>(BindingParameterCollection) GetProperty<T>(BindingParameterCollection)

从绑定堆栈的适当层返回所请求的类型化对象(如果存在)。Returns a typed object requested, if present, from the appropriate layer in the binding stack.

(Inherited from Binding)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ShouldSerializeName() ShouldSerializeName() ShouldSerializeName() ShouldSerializeName()

返回是否应序列化绑定名称。Returns whether the name of the binding should be serialized.

(Inherited from Binding)
ShouldSerializeNamespace() ShouldSerializeNamespace() ShouldSerializeNamespace() ShouldSerializeNamespace()

返回是否应序列化绑定命名空间。Returns whether the namespace of the binding should be serialized.

(Inherited from Binding)
ShouldSerializeSecurity() ShouldSerializeSecurity() ShouldSerializeSecurity() ShouldSerializeSecurity()

获取一个值,该值指定是否应序列化安全信息。Gets a value that specifies whether security information should be serialized.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于