SALES: 1-800-867-1380
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Add a Failure Notification Callback (Windows Server AppFabric Caching)

Windows Server AppFabric allows your cache-enabled application to receive cache notifications. This topic describes how to add a failure notification callback to your application. Failure notifications are triggered when the cache client misses one or more cache notifications. For more information about cache notifications in general, see Cache Notifications (Windows Server AppFabric Caching).

Similar to adding a callback for cache notifications, adding a callback for failure notifications involves two steps. First, create a method that should be invoked when a failure notification is triggered. The method you invoke with the failure notification must accept the same parameters as the DataCacheFailureNotificationCallback delegate. Second, add a callback for the failure notification using the AddFailureNotificationCallback method. Use the name of the method you created in the first step for the failureDelegate parameter.

noteNote
For your application to use notifications, you need to enable them on a named cache. Use the notificationsEnabled parameter with the New-Cache or Set-CacheConfig commands. For more information, see Using Windows PowerShell to Manage Windows Server AppFabric Caching Features.

To add a failure notification callback

  1. Create the method you want to be triggered by the failure notification. Make sure that the method you invoke with the failure notification accepts the same parameters as the DataCacheFailureNotificationCallback delegate.

  2. Add a callback for the failure notification using the AddFailureNotificationCallback method. Use the name of the method that you want to invoke when the failure notification occurs in the failureDelegate parameter.

Example

The first step when adding a failure notification callback is to create a method that you want to be invoked by the notification. The method called by the notification must accept the same parameters as the DataCacheFailureNotificationCallback delegate. This example shows one example of a method that can be invoked by a failure notification.

//method invoked by failure notification "ndNotificationFailure"
public void myNotificationFailureDelegate(string myCacheName,
    DataCacheNotificationDescriptor nd)
{
    Console.WriteLine("===============================");
    Console.WriteLine(" Invoked by failure notification");
    Console.WriteLine("===============================");
}

The second step is to add a callback for the failure notification. In this example, a failure notification is created to invoke the method from the previous example.

//add failure notification callback
DataCacheNotificationDescriptor ndNotificationFailure
    = myTestCache.AddFailureNotificationCallback(myNotificationFailureDelegate);

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft