# CommonX **Repository Path**: null_033_1186/CommonX ## Basic Information - **Project Name**: CommonX - **Description**: infrastructure by CommonX in NetStandard2.0 - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-07-24 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CommonX ## Getting Started ```C# namespace ServiceBus.TestPublish.NetCore { using CommonX.Components; using CommonX.Configurations; using CommonX.Logging; using System; using System.Reflection; using CommonX.ServiceBus.MassTransit.Configuration; using CommonX.ServiceBus; using CommonX.Log4Net; using CommonX.RabbitMQ; using CommonX.Kafka; using CommonX.EventBus.Events; using CommonX.EventBus.Abstractions; using Confluent.Kafka; using System.Threading.Tasks; using System.Collections.Generic; using CommonX.Quartz; using CommonX.Cache.Redis; public class RequestIntegrationEvent : IntegrationEvent { public string Message { get; set; } } public class RequestIntegrationEventHandler : IIntegrationEventHandler { public async Task Handle(RequestIntegrationEvent @event) { Console.WriteLine(@event.Id); Console.WriteLine(@event.CreationDate); Console.WriteLine(@event.Message); Console.WriteLine(@event.Id); await Task.FromResult(0); } } class Program { private static IBus _bus; private static ILogger _logger; private static IConnectionPool _conn; private static IConsumerClientFactory factory; private static IKafkaPersisterConnection _consumerClient; private static void HandlerMessage(Message msg) { Console.WriteLine($"消息的值为{msg.Value}"); } static void Main(string[] args) { Setup(); Console.WriteLine(); List topics = new List(); topics.Add("test"); _consumerClient.Consume(topics, HandlerMessage); _bus.Send("ServiceBus.TestPublish.NetCore", new RequestIntegrationEvent() { Message = "Masstransit test Succees!" }); _logger.Info("ServiceBus Logs test!!"); Console.WriteLine("Masstransit test Succees!"); Console.ReadKey(); } public static void Setup() { var assambly = Assembly.GetAssembly(typeof(Program)); var config = Configuration.Create() .UseAutofac() .RegisterCommonComponents() .UseLog4Net() .UseJsonNet() .UseQuartz(new Assembly[] { assambly }) .UseRabbitMQ(x=> { x.HostName = "localhost"; x.Port = 5067; x.VirtualHost = "/"; x.UserName = "guest"; x.Password = "guest"; x.AutomaticRecoveryEnabled = true; x.RequestedConnectionTimeout = 20000; }) .UseRedisCache() .UseMassTransit(new Assembly[] { assambly }) .UseKafka(""); using (var scope = ObjectContainer.Current.BeginLifetimeScope()) { _logger = scope.Resolve().Create(typeof(Program).Name); _bus = scope.Resolve(); _conn = scope.Resolve(); factory = scope.Resolve(); _consumerClient = scope.Resolve(); } } } } ```