2013-07-11 66 views
1

我正在爲我的appfabric緩存配置通知。第一個添加操作是發送一個通知。但是,當我用新值替換(更新)相同的緩存項目或刪除該項目時,我正在接收該單一操作的多個通知。我懷疑它與我執行的操作類型無關。因爲我看到了多個添加通知。有什麼配置我搞亂? 我已將代表寫入了我的代碼回覆文件。即使對於單一操作,它也持續地打擊代表一段時間。appfabric緩存中收到重複通知

我的配置是:

<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)); 

    } 

請讓我知道我失去了它?爲什麼它爲同一項目發送多個通知。如果它有任何用處,我正在使用兩臺主機的集羣。並且也使用相同的緩存進行會話管理。

回答

0

首先,確保你添加的只有一個回調。這很簡單,但我看到太多情況下添加了多個回調。

理解緩存通知是基於輪詢這是非常重要的。

當您使用緩存通知,要看到每隔一定的時間(pollInterval)緩存羣集的應用程序會檢查是否有新的通知可供選擇。

所以,如果你更新兩次檢查之間的10次的關鍵,你會得到10個通知。

+0

感謝Cyber​​maxs, 我所看到的,爲什麼出現了問題。我錯誤地爲每個操作添加了一個回調。但是,還有第二個問題被注意到。第一次輪詢後,應用程序幾乎在下一次操作之後立即收到通知,而不是等待下一輪詢。有任何想法嗎?? –