增加EventBus服务的文件配置:
new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddEventBusFile("eventBusSettings.json", optional: false);
增加EventBus服务的依赖注入:
new ContainerBuilder().RegisterServiceBus();
增加rabbitmq 服务配置:
UseRabbitMQTransport() //rabbitmq 服务配置
AddRabbitMQAdapt()//基于rabbitmq的消费的服务适配
增加订阅功能:
ServiceLocator.GetService< ISubscriptionAdapt >().SubscribeAt();
增加服务容错、服务容错降级、服务强制降级
- 增加容错策略Injection,脚本注入:
[Command(Strategy= StrategyType.Injection ,Injection = @"return null;")]
[Command(Strategy= StrategyType.Injection ,Injection = @"return Task.FromResult(new Surging.IModuleServices.Common.Models.UserModel { Name=""fanly"", Age=18 });",InjectionNamespaces =new string[] { "Surging.IModuleServices.Common"})]
- 增加容错策略Injection,本地模块注入:
[Command(Strategy= StrategyType.Injection ,Injection = @"return true;")]
增加缓存降级,怎么使用?
在业务接口方法上添加如下特性
[Command(Strategy= StrategyType.Failover,FailoverCluster =3,RequestCacheEnabled =true)] //RequestCacheEnabled =true 就是启用缓存
怎么拦截获取缓存
在业务接口方法上添加如下特性
[InterceptMethod(CachingMethod.Get, Key = "GetUser_id_{0}", Mode = CacheTargetType.Redis, Time = 480)]
怎么拦截删除缓存
在业务接口方法上添加如下特性
[InterceptMethod(CachingMethod.Remove, "GetUser_id_{0}", "GetUserName_name_{0}", Mode = CacheTargetType.Redis)]
怎么添加缓存KEY
在业务模型属性上添加,如下特性,可以支持多个
配置拦截器
.AddClientIntercepted(typeof(CacheProviderInterceptor))
IDE:Visual Studio 2017 15.3 Preview ,vscode
框架:.NET core 2.0
如有任何问题可以加入QQ群:615562965
[博客园]:https://www.cnblogs.com/fanliang11