NetEventRelayBinding 类
TOC
折叠目录
展开目录
本文由机器翻译。若要查看英语原文,请勾选“英语”复选框。 也可将鼠标指针移到文本上,在弹出窗口中显示英语原文。
翻译
英语

NetEventRelayBinding 类

 

表示支持单向事件多播,并允许任意数量的事件发布者和事件使用者以 rendezvous 在同一个终结点的绑定。

命名空间:   Microsoft.ServiceBus
程序集:  Microsoft.ServiceBus(Microsoft.ServiceBus.dll 中)

System.Object
  System.ServiceModel.Channels.Binding
    Microsoft.ServiceBus.NetOnewayRelayBinding
      Microsoft.ServiceBus.NetEventRelayBinding

public class NetEventRelayBinding : NetOnewayRelayBinding, IBindingRuntimePreferences

名称说明
System_CAPS_pubmethodNetEventRelayBinding()

新实例初始化 NetEventRelayBinding 类。

System_CAPS_pubmethodNetEventRelayBinding(EndToEndSecurityMode, RelayEventSubscriberAuthenticationType)

新实例初始化 NetEventRelayBinding 类,使用指定的安全模式和中继客户端身份验证类型。

System_CAPS_protmethodNetEventRelayBinding(RelayedOnewayTransportBindingElement, BinaryMessageEncodingBindingElement, NetOnewayRelaySecurity)

新实例初始化 NetEventRelayBinding 类,使用指定的传输、 编码和安全元素。

System_CAPS_pubmethodNetEventRelayBinding(String)

初始化的新实例 NetEventRelayBinding 类,使用指定的配置。

名称说明
System_CAPS_pubpropertyCloseTimeout

(从 Binding 继承。)

System_CAPS_pubpropertyEnvelopeVersion

获取用于此绑定处理的消息的 SOAP 版本。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyListenBacklog

获取或设置的最大可为挂起状态的排队的连接请求数。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyMaxBufferPoolSize

获取或设置用于存储由绑定处理的消息的缓冲区池的允许的最大大小。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyMaxBufferSize

获取或设置一个值,指定的最大大小,以字节为单位在内存中存储消息所用的缓冲区。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyMaxConnections

获取或设置一个值,控制最大连接可存入池中以备后续重复使用在客户端数和最大允许等待调度的服务器上的连接数。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyMaxReceivedMessageSize

获取或设置由绑定处理的接收消息的最大大小。(从 NetOnewayRelayBinding 继承。)

System_CAPS_protpropertyMessageSecurityVersion

获取消息安全版本。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyMessageVersion

(从 Binding 继承。)

System_CAPS_pubpropertyName

(从 Binding 继承。)

System_CAPS_pubpropertyNamespace

(从 Binding 继承。)

System_CAPS_pubpropertyOpenTimeout

(从 Binding 继承。)

System_CAPS_pubpropertyReaderQuotas

获取或设置可由采用此绑定配置的终结点处理的 SOAP 消息的复杂性约束。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertyReceiveTimeout

(从 Binding 继承。)

System_CAPS_pubpropertyScheme

获取传输的 URI 方案。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertySecurity

获取一个对象,指定与此绑定配置的服务使用的安全类型。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubpropertySendTimeout

(从 Binding 继承。)

名称说明
System_CAPS_protmethodApplyConfiguration(String)

适用于此绑定元素的当前实例的指定名称相对应的配置元素中的设置。(替代 NetOnewayRelayBinding.ApplyConfiguration(String)。)

System_CAPS_pubmethodBuildChannelFactory<TChannel>(BindingParameterCollection)

(从 Binding 继承。)

System_CAPS_pubmethodBuildChannelFactory<TChannel>(Object[])

(从 Binding 继承。)

System_CAPS_pubmethodBuildChannelListener<TChannel>(BindingParameterCollection)

(从 Binding 继承。)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Object[])

(从 Binding 继承。)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, BindingParameterCollection)

(从 Binding 继承。)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, Object[])

(从 Binding 继承。)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, BindingParameterCollection)

(从 Binding 继承。)

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

(从 Binding 继承。)

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

(从 Binding 继承。)

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

(从 Binding 继承。)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(BindingParameterCollection)

(从 Binding 继承。)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(Object[])

(从 Binding 继承。)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(BindingParameterCollection)

(从 Binding 继承。)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(Object[])

(从 Binding 继承。)

System_CAPS_pubmethodCreateBindingElements()

创建绑定元素的一组。(从 NetOnewayRelayBinding 继承。)

System_CAPS_pubmethodEquals(Object)

(从 Object 继承。)

System_CAPS_protmethodFinalize()

(从 Object 继承。)

System_CAPS_pubmethodGetHashCode()

(从 Object 继承。)

System_CAPS_pubmethodGetProperty<T>(BindingParameterCollection)

(从 Binding 继承。)

System_CAPS_pubmethodGetType()

(从 Object 继承。)

System_CAPS_protmethodIsBindingElementsMatch(RelayedOnewayTransportBindingElement, BinaryMessageEncodingBindingElement, ReliableSessionBindingElement)

检索一个值,确定指定的绑定元素是否与当前实例相匹配。

System_CAPS_protmethodMemberwiseClone()

(从 Object 继承。)

System_CAPS_pubmethodToString()

(从 Object 继承。)

名称说明
System_CAPS_protfieldencoding

表示绑定的编码。 以及安全设置和传输类型的编码表示绑定的三个核心属性。(从 NetOnewayRelayBinding 继承。)

System_CAPS_protfieldtransport

指定绑定的传输类型。 编码和安全设置,以及传输类型表示一个绑定的三个核心属性。(从 NetOnewayRelayBinding 继承。)

名称说明
System_CAPS_pubinterfaceSystem_CAPS_privpropertyIBindingRuntimePreferences.ReceiveSynchronously

获取一个值,该值指示是否可以更有效地同步或异步处理传入的请求。(从 NetOnewayRelayBinding 继承。)

Microsoft Azure Service Bus 只支持完全信任代码访问安全性。

System_CAPS_note注意

默认情况下, NetEventRelayBinding 使用传输安全。

NetEventRelayBinding 派生自 NetOnewayRelayBinding 在这种情况下, NetEventRelayBinding 继承的属性 NetOnewayRelayBinding 并共享其底层基础结构大部分与此绑定。

不同于任何其他的中继绑定, NetEventRelayBinding 在相同的 URI 上支持多个侦听器。 若要设置事件的事件 rendezvous (也称为主题) 的点,客户端和侦听器只是需要同意在一个解决方案的作用域内共享 URI 并将发送到或在其上侦听。 由任何客户端发送的消息获取分发到所有的侦听器。

对于当前版本中,侦听器数受到限制,以适合与少于 20 个并发侦听器的部门方案。 通过此绑定发送的消息被限制为最多 60 KB 的传输大小。

有关于序列或根本传递中到达的消息无任何保证。

采用其默认设置,NetEventRelayBinding 支持 SOAP 1.2 消息传递通过 TCP 使用.NET 进行组帧并通过.NET 二进制序列化。

服务和客户端使用了 NetEventRelayBinding 注册使用"sb"URI 方案中的,而不考虑活动连接模式的服务总线的终结点。

对通道进行受 SSL 保护如果 Security.Mode 属性设置为其中一个 EndToEndSecurityModeTransportTransportWithMessageCredential

传输通道保护可使所有通信,并从中继,但数据是对可见 (而不是通过观察到) 套接字中继点处的服务总线基础结构。

下面的示例演示如何定义和使用 NetEventRelayBinding 与服务和应用程序配置文件中的客户端的默认配置。

<system.serviceModel>

  <bindings>
    <netEventRelayBinding>
      <binding name="default" />
    </netEventRelayBinding>
  </bindings>

  <client>
    <endpoint name="RelayEndpoint"
              contract="Microsoft.ServiceBus.Samples.IMulticastContract"
              binding="netEventRelayBinding"
              bindingConfiguration="default"
              behaviorConfiguration="ReplaceWithEndpointBehaviorName"
              address="ReplaceWithEndpointAddress" />
  </client>

  <services>
    <service name="Microsoft.ServiceBus.Samples.MulticastService">
      <!-- Keep address empty to use host base address, or -->
      <!-- replace with endpoint address. -->
      <endpoint name="RelayEndpoint"
                contract="Microsoft.ServiceBus.Samples.IMulticastContract"
                binding="netEventRelayBinding"
                bindingConfiguration="default"
                behaviorConfiguration="ReplaceWithEndpointBehaviorName"
                address="" />
    </service>
  </services>

  <behaviors>
    <endpointBehaviors>
      <!-- Add endpoint behavior here. -->
    </endpointBehaviors>
  </behaviors>

</system.serviceModel>

下面的示例是与前面的示例类似,只不过它所定义的自定义配置 NetEventRelayBinding 它将客户端身份验证关闭,这意味着客户端不需要向 Service Bus 提供的安全令牌。

<system.serviceModel>

  <bindings>
    <!-- Application Binding -->
    <netEventRelayBinding>
        <!-- Turn off client authentication -->
      <binding name="customBinding">
        <security relayClientAuthenticationType="None" />
    </netEventRelayBinding>
  </bindings>

  <client>
    <!-- No behavior configuration is added to this endpoint as the client does not need to authenticate. -->
    <endpoint name="RelayEndpoint"
              contract="Microsoft.ServiceBus.Samples.IMulticastContract"
              binding="netEventRelayBinding"
              bindingConfiguration="customBinding"
              address="ReplaceWithEndpointAddress" />
  </client>

  <services>
    <service name="Microsoft.ServiceBus.Samples.MulticastService">
      <!-- Keep address empty to use host base address, or -->
      <!-- replace with endpoint address. -->
      <endpoint name="RelayEndpoint"
                contract="Microsoft.ServiceBus.Samples.IMulticastContract"
                binding="netEventRelayBinding"
                bindingConfiguration="customBinding"
                behaviorConfiguration="ReplaceWithEndpointBehaviorName"
                address="" />
    </service>
  </services>

  <behaviors>
    <endpointBehaviors>
      <!-- Add endpoint behavior here. -->
    </endpointBehaviors>
  </behaviors>

</system.serviceModel>

下面的示例演示如何使用 NetEventRelayBinding 以编程方式使用其默认设置。 默认设置 NetEventRelayBinding 进行端到端安全模式和客户端身份验证类型是 EndToEndSecurityMode.TransportRelayClientAuthenticationType.RelayAccessToken 分别。 此示例是修改的版本 Net Event 示例中,它指定服务终结点和以编程方式而不是指定它在应用程序配置文件中的客户端信道的绑定。 多播 SDK 示例是使用一个聊天应用程序 NetEventRelayBinding

该示例通过指定服务和客户端可能发送到 Service Bus 通过创建终结点行为的凭据来启动。 接下来,它创建绑定、 服务地址,并启动该多播的服务主机。 在开始后该服务,通道工厂为创建 IMulticastChannel 通道用来生成服务的客户端通道的类型。 最后,打开客户端通道。

// Configure the credentials for the service and client endpoints through an endpoint behavior.
TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
relayCredentials.TokenProvider = 
  TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, key);




// Create the binding with default settings.
NetEventRelayBinding binding = new NetEventRelayBinding();        

// Get the service URI.
Uri serviceAddress = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace,
       String.Format(CultureInfo.InvariantCulture, "{0}/MulticastService/", session));

// Create the Multicast service host.
ServiceHost host = new ServiceHost(typeof(MulticastService), serviceAddress);
// Add the service endpoint with the NetEventRelayBinding binding.
host.AddServiceEndpoint(typeof(IMulticastContract), binding, serviceAddress);
// Add the credentials through the endpoint behavior.
host.Description.Endpoints[0].Behaviors.Add(relayCredentials);
// Start the service.
host.Open();

// Create a channel factory for the IMulticastChannel channel type.
// This channel factory is used to create client channels to the Multicast service. 
// Each client channel the channel factory creates is configured to use the 
// NetEventRelayBinding that is passed to the constructor of the channel factory.
ChannelFactory<IMulticastChannel> channelFactory = new ChannelFactory<IMulticastChannel>(
    binding, new EndpointAddress(serviceAddress));
channelFactory.Endpoint.Behaviors.Add(relayCredentials);

// Create and open the client channel.
IMulticastChannel channel = channelFactory.CreateChannel();
channel.Open();

下面的示例是与前面的示例类似,只不过它使用 NetEventRelayBinding 使用自定义设置。 它将关闭客户端身份验证,这意味着客户端不需要提供安全令牌到 Service Bus。 由于客户端不需要进行身份验证,凭据没有终结点行为添加到客户端通道。 请注意因为服务应用程序始终使用 Service Bus 进行身份验证,行为仍添加到服务终结点。

// Configure the credentials for the service and client endpoints through an endpoint behavior.
TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
relayCredentials.TokenProvider = 
  TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, key);




// Create the binding with custom settings.
NetEventRelayBinding binding = new NetEventRelayBinding();        
// The client is not required to present a security token to the AppFabric Service Bus.
binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None;

// Get the service URI.
Uri serviceAddress = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace,
       String.Format(CultureInfo.InvariantCulture, "{0}/MulticastService/", session));

// Create the Multicast service host.
ServiceHost host = new ServiceHost(typeof(MulticastService), serviceAddress);
// Add the service endpoint with the NetEventRelayBinding binding.
host.AddServiceEndpoint(typeof(IMulticastContract), binding, serviceAddress);
// Add the credentials through the endpoint behavior.
host.Description.Endpoints[0].Behaviors.Add(relayCredentials);
// Start the service.
host.Open();

// Create a channel factory for the IMulticastChannel channel type.
// This channel factory is used to create client channels to the Multicast service. 
// Each client channel the channel factory creates is configured to use the 
// NetEventRelayBinding that is passed to the constructor of the channel factory.
ChannelFactory<IMulticastChannel> channelFactory = new ChannelFactory<IMulticastChannel>(
    binding, new EndpointAddress(serviceAddress));

// Create and open the client channel.
IMulticastChannel channel = channelFactory.CreateChannel();
channel.Open();

此类型的任何公共静态(Visual Basic 中为 Shared)成员都是线程安全的。但不保证所有实例成员都是线程安全的。

返回页首
显示:
© 2016 Microsoft