<sendMessageChannelCache>

一种服务行为,该行为支持缓存共享级别的自定义、通道工厂缓存的设置,以及使用 Send 消息传递活动将消息发送给服务终结点的工作流通道缓存的设置。

Schema Hierarchy

工作流的 <system.serviceModel>
  工作流的 <behaviors>
    工作流的 <serviceBehaviors>
      工作流的 <serviceBehaviors> 的 <behavior>
        <sendMessageChannelCache>

语法

<behaviors>  <serviceBehaviors>    <behavior name=String">       <sendMessageChannelCache allowUnsafeCaching="Boolean" >                   <channelSettings idleTimeout="TimeSpan" leaseTimeout="TimeSpan" maxItemsInCache="Integer" />           <factorySettings idleTimeout="TimeSpan" leaseTimeout="TimeSpan" maxItemsInCache="Integer" />       </sendMessageChannelCache>    </behavior>  </serviceBehaviors></behaviors>

特性和元素

以下几节描述了特性、子元素和父元素。

特性

特性 说明

allowUnsafeCaching

一个布尔值,该值指示是否启用缓存。如果工作流服务具有自定义绑定或自定义行为,缓存会变得不安全,因此默认情况下禁用缓存。但是,如果要启用缓存,请将此属性设置为 true

子元素

元素 说明

<channelSettings>

指定通道缓存的设置。

<factorySettings>

指定通道工厂缓存的设置。

父元素

元素 说明

工作流的 <serviceBehaviors> 的 <behavior>

指定行为元素。

备注

此服务行为适用于将消息发送给服务终结点的工作流。这些工作流是典型的客户端工作流,但也可以是在 WorkflowServiceHost 中承载的工作流服务。

默认情况下,在 WorkflowServiceHost 承载的工作流中,由 Send 消息传递活动使用的缓存可在 WorkflowServiceHost 中的所有工作流实例中共享(宿主级缓存)。对于不是由 WorkflowServiceHost 承载的客户端工作流,该缓存仅对工作流实例可用(实例级缓存)。对于已在配置中定义了终结点的工作流中的所有 Send 活动,默认情况下为禁用缓存。

有关如何更改默认的缓存共享级别以及通道工厂和通道缓存的缓存设置的更多信息,请参见Changing the Cache Sharing Levels for Send Activities

示例

在承载的工作流服务中,可以在应用程序配置文件中指定工厂缓存和通道缓存设置。为此,应添加一个包含工厂和通道缓存的缓存设置的服务行为,并将此服务行为添加到您的服务中。下面的示例演示包含 **MyChannelCacheBehavior **服务行为(具有自定义工厂缓存和通道缓存设置)的配置文件的内容。此服务行为通过 **behaviorConfiguarion **特性添加到服务中。

<configuration>  
  <system.serviceModel>
    <!-- List of other config sections here --> 
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyChannelCacheBehavior">
          <sendMessageChannelCache allowUnsafeCaching ="false" >
            <!-- Control only the host level settings --> 
            <factorySettings maxItemsInCache = "8" idleTimeout = "00:05:00" leaseTimeout="10:00:00" />
            <channelSettings maxItemsInCache = "32" idleTimeout = "00:05:00" leaseTimeout="00:06:00" />
          </sendMessageChannelCache>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="MyService" behaviorConfiguration="MyChannelCacheBehavior" />
    </services>
  </system.serviceModel>
</configuration> 

另请参见

参考

SendMessageChannelCache
SendMessageChannelCacheElement
Send

其他资源

Changing the Cache Sharing Levels for Send Activities

生成日期:2010-02-13