{"id":21968455,"url":"https://github.com/duyanming/dymdemo","last_synced_at":"2025-10-11T20:45:08.495Z","repository":{"id":100810191,"uuid":"190519189","full_name":"duyanming/dymDemo","owner":"duyanming","description":"Anno 分布式 开发框架  Demo RPC  Thrift  GRPC 插件开发  java Anno","archived":false,"fork":false,"pushed_at":"2020-07-31T02:22:50.000Z","size":453,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T07:17:07.563Z","etag":null,"topics":["anno","dym","eventbus","grpc","microservice","netcore","thrift"],"latest_commit_sha":null,"homepage":"https://duyanming.github.io/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duyanming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-06T05:23:16.000Z","updated_at":"2025-02-19T10:25:50.000Z","dependencies_parsed_at":"2023-06-28T19:31:00.122Z","dependency_job_id":null,"html_url":"https://github.com/duyanming/dymDemo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FdymDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FdymDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FdymDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyanming%2FdymDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duyanming","download_url":"https://codeload.github.com/duyanming/dymDemo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250580756,"owners_count":21453538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anno","dym","eventbus","grpc","microservice","netcore","thrift"],"created_at":"2024-11-29T13:56:01.223Z","updated_at":"2025-10-11T20:45:03.473Z","avatar_url":"https://github.com/duyanming.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnnoDemo\n\n    Anno 分布式开发框架 Demo\n##  [Java 实现 ](https://github.com/duyanming/anno.thrift-parent) : https://github.com/duyanming/anno.thrift-parent\n\n##  [Demo 在线演示地址](http://140.143.207.244) :http://140.143.207.244\n    账号：anno\n    密码：123456\n\n# Anno 分布式开发框架\n\n    Anno 是一个分布式开发框架，同时支持 .net core3.0 、.net frameworker4.6.1。\n\n## 1、运行Demo\n    第一步：启动注册中心\n        进入项目文件夹 AnnoDemo\\YY.AppCenter\\bin\\Debug\\netcoreapp3.0 ，运行命令 dotnet AppCenter.dll\n        看到下图 说明运行成功\n![第一步](https://s1.ax1x.com/2020/07/31/aMvkdg.png)\n\n    第二步：启动Server  \n        Server可以和 AppCenter 不在同一台电脑，也可以运行多个server 也可以负载均衡，高级用法随后介绍\n        进入项目文件夹 AnnoDemo\\YY.Server\\bin\\Debug\\netcoreapp3.0 ，运行命令 dotnet YY.Server.dll\n        看到下图 说明 Server 成功运行 并且已经注册到 注册中心（APPCenter）运行成功\n![第二步](https://s1.ax1x.com/2020/07/31/aMvAoQ.png)\n\n    第三步：启动Client\n        启动Client 测试 Client调用 Server是否成功\n        进入项目文件夹 AnnoDemo\\YY.Client\\bin\\Debug\\netcoreapp3.0 ，运行命令 dotnet YY.Client.dll\n        看到下图 说明 Client 成功运行 \n![第三步](https://s1.ax1x.com/2020/07/31/aMvFeS.png)\n\n    第三步：启动YYWeb\n\n![第四步](https://s1.ax1x.com/2020/07/31/aMvPL8.png)\n\n# Anno EventBus\n    Eventbus Support  InMemory and Rabbitmq\n## 1、Server配置\n\n```c#\n\t//指定EventHandler的 所在程序集\n\tvar funcs = Anno.Const.Assemblys.Dic.Values.ToList();\n                #region RabbitMQEventBus\n                //消费失败通知\n\n                RabbitMQEventBus.Instance.ErrorNotice += (string exchange, string routingKey, Exception exception, string body) =\u003e\n                        {\n                            Log.Fatal(new { exchange, routingKey, exception, body }, typeof(RabbitMQEventBus));\n                        };\n                EventBusSetting.Default.RabbitConfiguration = new RabbitConfiguration()\n                {\n                    HostName = \"192.168.100.173\",\n                    VirtualHost = \"dev\",\n                    UserName = \"dev\",\n                    Password = \"dev\",\n                    Port = 5672\n                };\n                RabbitMQEventBus.Instance.SubscribeAll(funcs);\n\n                #endregion\n                #region InMemory EventBus\n                EventBus.Instance.ErrorNotice += (string exchange, string routingKey, Exception exception, string body) =\u003e\n                {\n                    Log.Fatal(new { exchange, routingKey, exception, body }, typeof(EventBus));\n                };\n                EventBus.Instance.SubscribeAll(funcs);\n\n```\n\n## 2、EventData配置\n\n```c#\n\n\tusing Anno.EventBus;\n\t\n\tnamespace Events\n\t{\n\t    public class FirstMessageEvent:EventData\n\t    {\n\t        public string Message { get; set; }\n\t    }\n\t}\n\n```\n\n\n## 3、EventHandler配置\n\n```c#\n\t\n\tnamespace Anno.Plugs.SamsundotService.EventHandler\n\t{\n\t    using Anno.EventBus;\n\t    using Events;\n\t\n\t    class FirstMessageEventHandler : IEventHandler\u003cFirstMessageEvent\u003e\n\t    {\n\t        public void Handler(FirstMessageEvent entity)\n\t        {\n\t            Log.Log.Info(new { Plugs= \"Samsundot\",Entity=entity },typeof(FirstMessageEventHandler));\n\t        }\n\t    }\n\t}\n\n```\n\n ```c#\n\t\n\tnamespace Anno.Plugs.YYTestService.EventHandler\n\t{\n\t    using Anno.EventBus;\n\t    using Events;\n\t\n\t    class FirstMessageEventHandler : IEventHandler\u003cFirstMessageEvent\u003e\n\t    {\n\t        public void Handler(FirstMessageEvent entity)\n\t        {\n\t            Log.Log.Info(new { Plugs = \"YYTest\", Entity = entity }, typeof(FirstMessageEventHandler));\n\t        }\n\t    }\n\t    /// \u003csummary\u003e\n\t    /// 异常消费演示，测试 消费失败通知\n\t    /// \u003c/summary\u003e\n\t    class FirstMessageExceptionEventHandler : IEventHandler\u003cFirstMessageEvent\u003e\n\t    {\n\t        public void Handler(FirstMessageEvent entity)\n\t        {\n\t            Log.Log.Info(new { Plugs = \"YYTest\",Handle= \"FirstMessageExceptionEventHandler\", Entity = entity }, typeof(FirstMessageEventHandler));\n\t            throw new Exception(\"异常消费演示，测试 消费失败通知 From FirstMessageExceptionEventHandler!\");\n\t        }\n\t    }\n\t}\n\n ```\n\n## 4、中间件\n### 4.1 缓存中间件\n#### nuget install\n\n```shell\n\nInstall-Package Anno.EngineData.Cache\n\n```\n\n ```c#\n\t\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing Anno.EngineData;\nusing Anno.EngineData.Cache;\n\n\nnamespace Anno.Plugs.CacheRateLimitService\n{\n    public class CacheModule : BaseModule\n    {\n        /*\n        参数1：缓存长度\n        参数2：缓存存活时间\n        参数3：缓存存活时间是否滑动\n        */\n        [CacheLRU(5,6,true)]\n        public ActionResult Cache(string msg)\n        {\n            Console.WriteLine(msg);\n            return new ActionResult(true, null,null,msg);\n        }\n    }\n}\n\n ```\n\n ### 4.2 缓存中间件\n#### nuget install\n\n```shell\n\nInstall-Package Anno.EngineData.RateLimit\n\n```\n\n ```c#\n\t\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing Anno.EngineData;\nusing Anno.RateLimit;\n\nnamespace Anno.Plugs.CacheRateLimitService\n{\n    public class LimitModule : BaseModule\n    {\n        /*\n        参数1：限流算法是令牌桶还是漏桶\n        参数2：限流时间片段单位秒\n        参数3：单位时间可以通过的请求个数\n        参数4：桶容量\n        */\n        [EngineData.Limit.RateLimit(LimitingType.TokenBucket,1,5,5)]\n        public ActionResult Limit(string msg)\n        {\n            Console.WriteLine(msg);\n            return new ActionResult(true, null, null, msg);\n        }\n    }\n}\n\n ```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduyanming%2Fdymdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduyanming%2Fdymdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduyanming%2Fdymdemo/lists"}