【问题标题】:Duplicate Notifications are being received in appfabric caching在 appfabric 缓存中收到重复通知
【发布时间】:2013-07-11 06:49:07
【问题描述】:

我正在为我的 appfabric 缓存配置通知。第一个添加操作是发送一个通知。但是,当我用新值替换(更新)相同的缓存项或删除该项时,我会收到针对该单个操作的多个通知。我怀疑这与我执行的操作类型无关。因为我也看到了多个添加通知。有没有我搞砸的配置? 我已经在我的 codeback 文件中编写了委托。即使是单次操作,它也会在一段时间内持续打击委托。

我的配置是:

<dataCacheClient requestTimeout="150000" channelOpenTimeout="19000" maxConnectionsToServer="10">
    <localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
    <clientNotification pollInterval="30" maxQueueLength="10000" />
    <hosts>
        <host name="192.10.14.20" cachePort="22233"/>

    </hosts>
    <securityProperties mode="None" protectionLevel="None" />
    <transportProperties connectionBufferSize="131072" maxBufferPoolSize="268435456"
                         maxBufferSize="8388608" maxOutputDelay="2" channelInitializationTimeout="60000"
                         receiveTimeout="600000"/>
</dataCacheClient>

我有委托的代码是:

  public void myCacheLvlDelegate(string myCacheName, string myRegion, string myKey, DataCacheItemVersion itemVersion, DataCacheOperations OperationId, DataCacheNotificationDescriptor nd)
    {
        //display some of the delegate parameters
        StringBuilder ResponseOfCache = new StringBuilder("A cache-level notification was triggered!");
        ResponseOfCache.Append("   ; Cache: " + myCacheName);
        ResponseOfCache.Append("   ; Region: " + myRegion);
        ResponseOfCache.Append("   ; Key: " + myKey);
        ResponseOfCache.Append("   ; Operation: " + OperationId.ToString());
        string value = ManualDataCacheOperations.GetCacheValue(myTestCache, txtKey.Text).ToString();
        Legend.Append(string.Format("{0} - Operation {1} Performed at {2}{3}", myKey, OperationId.ToString(), DateTime.Now.ToShortTimeString(), Environment.NewLine));

    }

请告诉我我在哪里错过它?为什么它会为同一项目发送多个通知。如果有任何用处,我正在使用具有两台主机的集群。并且也使用相同的缓存进行会话管理。

【问题讨论】:

    标签: caching notifications duplicates appfabric


    【解决方案1】:

    首先,确保您只添加了一个回调。这很简单,但我见过太多添加多个回调的情况。

    了解缓存通知是基于轮询的,这一点非常重要。

    当您使用缓存通知时,您的应用程序会定期检查缓存集群 (pollInterval) 以查看是否有任何新通知可用。

    因此,如果您在两次检查之间更新 10 次密钥,您将收到 10 次通知。

    【讨论】:

    • 感谢 Cyber​​maxs ,我知道为什么会出现问题。我错误地为每个操作添加了回调。但是,注意到了第二个问题。第一次轮询后,应用程序在下一次操作后几乎立即收到通知,而不是等待下一次轮询。有什么想法吗??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-31
    • 2011-12-24
    • 2011-08-17
    相关资源
    最近更新 更多