你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
FabricClient.ServiceManagementClient.ServiceNotificationFilterMatched 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当以前通过 注册RegisterServiceNotificationFilterAsync(ServiceNotificationFilterDescription)的 与系统中的服务终结点更改匹配时ServiceNotificationFilterDescription引发。
public event EventHandler ServiceNotificationFilterMatched;
member this.ServiceNotificationFilterMatched : EventHandler
Public Event ServiceNotificationFilterMatched As EventHandler
事件类型
示例
以下示例演示如何注册和处理服务通知:
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);
}
}
}
注解
事件参数的类型 FabricClient.ServiceManagementClient.ServiceNotificationEventArgs为 。