{"id":18739954,"url":"https://github.com/withlin/commonx","last_synced_at":"2025-04-12T20:04:45.375Z","repository":{"id":96510431,"uuid":"120299670","full_name":"withlin/CommonX","owner":"withlin","description":"基础框架","archived":false,"fork":false,"pushed_at":"2018-06-04T12:34:39.000Z","size":17039,"stargazers_count":57,"open_issues_count":0,"forks_count":21,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T20:04:38.062Z","etag":null,"topics":["autofac","esb","kafka","log4net","mapster","masstransit","quartz","rabbitmq","redis","zookeeper"],"latest_commit_sha":null,"homepage":"","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/withlin.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":"2018-02-05T12:07:28.000Z","updated_at":"2023-12-12T08:43:47.000Z","dependencies_parsed_at":"2023-03-16T03:31:36.988Z","dependency_job_id":null,"html_url":"https://github.com/withlin/CommonX","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2FCommonX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2FCommonX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2FCommonX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2FCommonX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/withlin","download_url":"https://codeload.github.com/withlin/CommonX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"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":["autofac","esb","kafka","log4net","mapster","masstransit","quartz","rabbitmq","redis","zookeeper"],"created_at":"2024-11-07T15:37:59.532Z","updated_at":"2025-04-12T20:04:45.368Z","avatar_url":"https://github.com/withlin.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CommonX\n\n## Getting Started\n```C#\nnamespace ServiceBus.TestPublish.NetCore\n{\n    using CommonX.Components;\n    using CommonX.Configurations;\n    using CommonX.Logging;\n    using System;\n    using System.Reflection;\n    using CommonX.ServiceBus.MassTransit.Configuration;\n    using CommonX.ServiceBus;\n    using CommonX.Log4Net;\n    using CommonX.RabbitMQ;\n    using CommonX.Kafka;\n    using CommonX.EventBus.Events;\n    using CommonX.EventBus.Abstractions;\n    using Confluent.Kafka;\n    using System.Threading.Tasks;\n    using System.Collections.Generic;\n    using CommonX.Quartz;\n    using CommonX.Cache.Redis;\n\n    public class RequestIntegrationEvent : IntegrationEvent\n    {\n        public string Message { get; set; }\n    }\n    public class RequestIntegrationEventHandler : IIntegrationEventHandler\u003cRequestIntegrationEvent\u003e\n    {\n        public async Task Handle(RequestIntegrationEvent @event)\n        {\n            Console.WriteLine(@event.Id);\n            Console.WriteLine(@event.CreationDate);\n            Console.WriteLine(@event.Message);\n            Console.WriteLine(@event.Id);\n            await Task.FromResult(0);\n        }\n    }\n\n    class Program\n    {\n        private static IBus _bus;\n        private static ILogger _logger;\n        private static IConnectionPool _conn;\n        private static IConsumerClientFactory factory;\n        private static IKafkaPersisterConnection _consumerClient;\n        private static void HandlerMessage(Message\u003cstring, string\u003e msg)\n        {\n            Console.WriteLine($\"消息的值为{msg.Value}\");\n        }\n        static void Main(string[] args)\n        {\n            Setup();\n            Console.WriteLine();\n            List\u003cstring\u003e topics = new List\u003cstring\u003e();\n            topics.Add(\"test\");\n            _consumerClient.Consume(topics, HandlerMessage);\n\n\n\n            _bus.Send(\"ServiceBus.TestPublish.NetCore\", new RequestIntegrationEvent() { Message = \"Masstransit test Succees!\" });\n            _logger.Info(\"ServiceBus Logs test!!\");\n            Console.WriteLine(\"Masstransit test Succees！\");\n            Console.ReadKey();\n        }\n\n        public static void Setup()\n        {\n            var assambly = Assembly.GetAssembly(typeof(Program));\n            var config = Configuration.Create()\n                .UseAutofac()\n                .RegisterCommonComponents()\n                .UseLog4Net()\n                .UseJsonNet()\n                .UseQuartz(new Assembly[] { assambly })\n                .UseRabbitMQ(x=\u003e \n                {\n                    x.HostName = \"localhost\";\n                    x.Port = 5067;\n                    x.VirtualHost = \"/\";\n                    x.UserName = \"guest\";\n                    x.Password = \"guest\";\n                    x.AutomaticRecoveryEnabled = true;\n                    x.RequestedConnectionTimeout = 20000;\n                })\n                .UseRedisCache()\n                .UseMassTransit(new Assembly[] { assambly })\n                .UseKafka(\"\");\n\n            using (var scope = ObjectContainer.Current.BeginLifetimeScope())\n            {\n                _logger = scope.Resolve\u003cILoggerFactory\u003e().Create(typeof(Program).Name);\n                _bus = scope.Resolve\u003cIBus\u003e();\n                _conn = scope.Resolve\u003cIConnectionPool\u003e();\n                factory = scope.Resolve\u003cIConsumerClientFactory\u003e();\n                _consumerClient = scope.Resolve\u003cIKafkaPersisterConnection\u003e();\n            }\n        }\n    }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithlin%2Fcommonx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwithlin%2Fcommonx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithlin%2Fcommonx/lists"}