Dashboard介绍
capOptions.UseDashboard(dashoptions => { dashoptions.AppPath = "applicationpath"; dashoptions.PathMatch = "/cap"; dashoptions.Authorization = new[] { new CapDashboardFilter() }; });
这里只说这几个参数
AppPath:应用程序路径 访问dashboard的时候会有一个返回应用的操作,这个即是应用的地址
PathMatch:不设置的情况下都是cap,可以指定自己的dashboard路由地址
Authorization:授权处理
授权处理具体实现
只需要实现接口IDashboardAuthorizationFilter即可
public class CapDashboardFilter : IDashboardAuthorizationFilter { public bool Authorize(DashboardContext context) { return true; } }
通过DashboardContext上下文处理请求,允许返回true,不允许返回false
结合Exceptionless
先看下面的代码
capOptions.FailedRetryCount = capConfig.FailedRetryCount; capOptions.FailedRetryInterval = capConfig.FailedRetryInterval; capOptions.FailedThresholdCallback = (msg, msgName, msgConent) => { //发布消息失败记录日志 if (msg == DotNetCore.CAP.Models.MessageType.Publish) { ExceptionlessClient.Default.CreateLog("PubishFailed", msgName + ":" + msgConent, Exceptionless.Logging.LogLevel.Info).AddTags("PubishFailed").Submit(); } if (msg == DotNetCore.CAP.Models.MessageType.Subscribe) { ExceptionlessClient.Default.CreateLog("SubscribeFailed", msgName + ":" + msgConent, Exceptionless.Logging.LogLevel.Info).AddTags("SubscribeFailed").Submit(); } };
FailedRetryCount:指定失败重试的次数 默认记得是50次吧
FailedRetryInterval:重试的时间
FailedThresholdCallback:最终执行失败回调方法,回调方法里面有3个参数 (消息类型、消息名称、消息内容)通过发布、订阅类型处理日志 方便执行失败对数据造成的不一致性,在某一刻可以人为的添加上
Exceptionless的相关配置详见我的另外一篇文章 https://www.cnblogs.com/liyouming/p/9167624.html