Compartilhar via


FabricClient.ServiceManagementClient.ServiceNotificationFilterMatched Evento

Definição

Gerado quando um ServiceNotificationFilterDescription registrado anteriormente por meio RegisterServiceNotificationFilterAsync(ServiceNotificationFilterDescription) é correspondido pelas alterações de ponto de extremidade de um serviço no sistema.

public event EventHandler ServiceNotificationFilterMatched;
member this.ServiceNotificationFilterMatched : EventHandler 
Public Event ServiceNotificationFilterMatched As EventHandler 

Tipo de evento

Exemplos

O exemplo a seguir mostra como se registrar e processar notificações de serviço:

namespace ServiceNotificationsExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new FabricClient(new string[] { "[cluster_endpoint]:[client_port]" });

            var filter = new ServiceNotificationFilterDescription()
            {
                Name = new Uri("fabric:/my_application"),
                MatchNamePrefix = true,
            };

            client.ServiceManager.ServiceNotificationFilterMatched += (s, e) => OnNotification(e);

            var filterId = client.ServiceManager.RegisterServiceNotificationFilterAsync(filter).Result;

            Console.WriteLine(
                "Registered filter: name={0} id={1}",
                filter.Name,
                filterId);

            Console.ReadLine();

            client.ServiceManager.UnregisterServiceNotificationFilterAsync(filterId).Wait();

            Console.WriteLine(
                "Unregistered filter: name={0} id={1}",
                filter.Name,
                filterId);
        }

        private static void OnNotification(EventArgs e)
        {
            var castedEventArgs = (FabricClient.ServiceManagementClient.ServiceNotificationEventArgs)e;

            var notification = castedEventArgs.Notification;

            Console.WriteLine(
                "[{0}] received notification for service '{1}'",
                DateTime.UtcNow,
                notification.ServiceName);
        }
    }
}

Comentários

O argumento event é do tipo FabricClient.ServiceManagementClient.ServiceNotificationEventArgs.

Aplica-se a