오류 알림 콜백 추가(Windows Server AppFabric 캐싱)

Windows Server AppFabric을 사용하면 캐시 사용 응용 프로그램이 캐시 알림을 받을 수 있습니다. 이 항목에서는 응용 프로그램에 오류 알림 콜백을 추가하는 방법에 대해 설명합니다. 오류 알림은 캐시 클라이언트에서 하나 이상의 캐시 알림이 누락된 경우에 트리거됩니다. 일반적인 캐시 알림에 대한 자세한 내용은 캐시 알림(Windows Server AppFabric 캐싱)을 참조하십시오.

캐시 알림 콜백 추가와 마찬가지로 오류 알림 콜백 추가는 두 단계로 이루어집니다. 첫째, 오류 알림이 트리거될 때 호출할 메서드를 만듭니다. 오류 알림을 사용하여 호출하는 메서드는 DataCacheFailureNotificationCallback 대리자와 동일한 매개 변수를 사용해야 합니다. 둘째, AddFailureNotificationCallback 메서드를 사용하여 오류 알림 콜백을 추가합니다. 첫 번째 단계에서 만든 메서드의 이름을 failureDelegate 매개 변수에 사용합니다.

참고

응용 프로그램이 알림을 사용하려면 명명된 캐시에서 알림을 사용하도록 설정해야 합니다. New-Cache 또는 Set-CacheConfig 명령에 notificationsEnabled 매개 변수를 사용합니다. 자세한 내용은 Windows PowerShell을 사용하여 Windows Server AppFabric 캐싱 기능 관리를 참조하십시오.

오류 알림 콜백을 추가하려면 다음을 수행하십시오.

  1. 오류 알림에서 트리거할 메서드를 만듭니다. 오류 알림을 사용하여 호출하는 메서드는 DataCacheFailureNotificationCallback 대리자와 동일한 매개 변수를 사용해야 합니다.

  2. AddFailureNotificationCallback 메서드를 사용하여 오류 알림 콜백을 추가합니다. 오류 알림이 발생할 때 호출할 메서드의 이름을 failureDelegate 매개 변수에 사용합니다.

예제

오류 알림 콜백을 추가하는 첫 번째 단계에서는 알림에서 트리거할 메서드를 만듭니다. 알림에서 호출하는 메서드는 DataCacheFailureNotificationCallback 대리자와 동일한 매개 변수를 사용해야 합니다. 이 예에서는 오류 알림에서 호출할 수 있는 메서드의 한 예를 보여 줍니다.

'method invoked by failure notification "ndNotificationFailure"
Public Sub myNotificationFailureDelegate(ByVal myCacheName As String, _
    ByVal nd As DataCacheNotificationDescriptor)

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

두 번째 단계에서는 오류 알림 콜백을 추가합니다. 이 예에서는 이전 예의 메서드를 호출할 오류 알림을 만듭니다.

'add failure notification callback
Dim ndNotificationFailure As DataCacheNotificationDescriptor
ndNotificationFailure = _
    myTestCache.AddFailureNotificationCallback(AddressOf myNotificationFailureDelegate)
//add failure notification callback
DataCacheNotificationDescriptor ndNotificationFailure
    = myTestCache.AddFailureNotificationCallback(myNotificationFailureDelegate);

참고 항목

개념

캐시 알림 콜백 추가(Windows Server AppFabric 캐싱)
캐시 알림 콜백 제거(Windows Server AppFabric 캐싱)
캐시 알림 메서드(Windows Server AppFabric 캐싱)
Windows PowerShell을 사용하여 Windows Server AppFabric 캐싱 기능 관리

  2011-12-05