private void StartMessageQueueComponents() { #region event subscriber init _domainEventProcessor = MessageQueueFactory.CreateEventSubscriber(new[] { new TopicSubscription(Consts.DemoEventTopic), }, Consts.DemoEventSubscriber, Environment.MachineName, new[] { Consts.DemoDomainEventSubscriberProvider }); _domainEventProcessor.Start(); #endregion #region EventPublisher init _messagePublisher = MessageQueueFactory.GetMessagePublisher(); _messagePublisher.Start(); #endregion }
private void StartMessageQueueComponents() { #region Command Consuemrs init var commandQueueName = $"{TopicPrefix}commandqueue"; _commandConsumer1 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "0", new[] { "CommandHandlers" }); _commandConsumer1.Start(); //_commandConsumer2 = // MessageQueueFactory.CreateCommandConsumer(commandQueueName, "1", new[] { "CommandHandlers" }); //_commandConsumer2.Start(); //_commandConsumer3 = // MessageQueueFactory.CreateCommandConsumer(commandQueueName, "2", new[] { "CommandHandlers" }); //_commandConsumer3.Start(); #endregion #region event subscriber init _domainEventProcessor = MessageQueueFactory.CreateEventSubscriber(new[] { new TopicSubscription($"{TopicPrefix}DomainEvent"), new TopicSubscription($"{TopicPrefix}ProductDomainEvent") }, "DomainEventSubscriber", Environment.MachineName, new[] { "DomainEventSubscriber" }); _domainEventProcessor.Start(); #endregion #region application event subscriber init _applicationEventProcessor = MessageQueueFactory.CreateEventSubscriber($"{TopicPrefix}AppEvent", "AppEventSubscriber", Environment.MachineName, new[] { "ApplicationEventSubscriber" }); _applicationEventProcessor.Start(); #endregion #region EventPublisher init _messagePublisher = MessageQueueFactory.GetMessagePublisher(); _messagePublisher.Start(); #endregion #region CommandBus init _commandBus = MessageQueueFactory.GetCommandBus(); _commandBus.Start(); #endregion }
public static void Bootstrap() { try { Configuration.Instance .UseLog4Net() .MessageQueueUseMachineNameFormat() .UseMessageQueue() .UseMessageStore <SampleModelContext>() //.UseKafka("localhost:2181") .UseEQueue(Utility.GetLocalIPV4().ToString()) .UseCommandBus(Environment.MachineName, linerCommandManager: new Sample.Command.LinearCommandManager()) .UseMessagePublisher("eventTopic"); _Logger = IoCFactory.Resolve <ILoggerFactory>().Create(typeof(WebApiApplication).Name); _Logger.Debug($"App Started"); #region EventPublisher init _MessagePublisher = MessageQueueFactory.GetMessagePublisher(); _MessagePublisher.Start(); #endregion #region event subscriber init _DomainEventConsumer = MessageQueueFactory.CreateEventSubscriber("DomainEvent", "DomainEventSubscriber", Environment.MachineName, "DomainEventSubscriber"); _DomainEventConsumer.Start(); #endregion #region application event subscriber init _ApplicationEventConsumer = MessageQueueFactory.CreateEventSubscriber("AppEvent", "AppEventSubscriber", Environment.MachineName, "ApplicationEventSubscriber"); _ApplicationEventConsumer.Start(); #endregion #region CommandBus init _CommandBus = MessageQueueFactory.GetCommandBus(); _CommandBus.Start(); #endregion #region Command Consuemrs init' var commandQueueName = "commandqueue"; _CommandConsumer1 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "0", "CommandHandlers"); _CommandConsumer1.Start(); _CommandConsumer2 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "1", "CommandHandlers"); _CommandConsumer2.Start(); _CommandConsumer3 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "2", "CommandHandlers"); _CommandConsumer3.Start(); #endregion } catch (Exception ex) { _Logger.Error(ex.GetBaseException().Message, ex); } }
private static void StartMessageQueueComponents() { #region Command Consuemrs init var commandQueueName = "commandqueue"; _commandConsumer1 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "0", new[] { "CommandHandlers" }); _commandConsumer1.Start(); _commandConsumer2 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "1", new[] { "CommandHandlers" }); _commandConsumer2.Start(); _commandConsumer3 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "2", new[] { "CommandHandlers" }); _commandConsumer3.Start(); #endregion #region event subscriber init _domainEventProcessor = MessageQueueFactory.CreateEventSubscriber("DomainEvent", "DomainEventSubscriber", Environment.MachineName, new[] { "DomainEventSubscriber" }); _domainEventProcessor.Start(); #endregion #region application event subscriber init _applicationEventProcessor = MessageQueueFactory.CreateEventSubscriber("AppEvent", "AppEventSubscriber", Environment.MachineName, new[] { "ApplicationEventSubscriber" }); _applicationEventProcessor.Start(); #endregion #region EventPublisher init _messagePublisher = MessageQueueFactory.GetMessagePublisher(); _messagePublisher.Start(); #endregion #region CommandBus init _commandBus = MessageQueueFactory.GetCommandBus(); _commandBus.Start(); #endregion }
void Application_Start(object sender, EventArgs e) { try { var queue = "Classic.MyCommand"; var topic = "MyEvent"; string appName = $"{Environment.MachineName}.ClassicApp"; string subscription = "subscription"; Configuration.Instance .UseLog4Net() .UseMessageQueue(appName) .UseKafka("localhost:2181") .UseCommandBus(appName) .UseMessagePublisher(topic); ErrorCodeDictionaryInitializer.Init(); _messagePublisher = MessageQueueFactory.GetMessagePublisher(); _messagePublisher.Start(); _commandBus = MessageQueueFactory.GetCommandBus(); _commandBus.Start(); _commandConsumer = MessageQueueFactory.CreateCommandConsumer(queue, appName, "commandHandlerProvider"); _commandConsumer.Start(); var subscribedTopic = $"{appName}.{topic}"; // 创建事件订阅器并启动开始消费消息 _eventSubscriber = MessageQueueFactory.CreateEventSubscriber(subscribedTopic, subscription, appName, "eventHandlerProvider"); _eventSubscriber.Start(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } catch (Exception ex) { Debug.WriteLine(ex.GetBaseException().Message); } // Code that runs on application startup }
public static void Bootstrap() { try { var kafkaBrokerList = new[] { new IPEndPoint(Utility.GetLocalIPV4(), 9092).ToString(), //"192.168.99.60:9092" }; Configuration.Instance .UseLog4Net("CommandService") .MessageQueueUseMachineNameFormat() .UseMessageQueue() .UseMessageStore <SampleModelContext>() .UseInMemoryMessageQueue() //.UseConfluentKafka(string.Join(",", kafkaBrokerList)) //.UseKafka("localhost:2181") //.UseEQueue() .UseCommandBus(Environment.MachineName, linerCommandManager: new LinearCommandManager()) .UseMessagePublisher("eventTopic"); _Logger = IoCFactory.Resolve <ILoggerFactory>().Create(typeof(WebApiApplication).Name); _Logger.Debug($"App Started"); #region Command Consuemrs init var commandQueueName = "commandqueue"; _CommandConsumer1 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "0", new[] { "CommandHandlers" }); _CommandConsumer1.Start(); _CommandConsumer2 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "1", new[] { "CommandHandlers" }); _CommandConsumer2.Start(); _CommandConsumer3 = MessageQueueFactory.CreateCommandConsumer(commandQueueName, "2", new[] { "CommandHandlers" }); _CommandConsumer3.Start(); #endregion #region event subscriber init _DomainEventConsumer = MessageQueueFactory.CreateEventSubscriber("DomainEvent", "DomainEventSubscriber", Environment.MachineName, new[] { "DomainEventSubscriber" }); _DomainEventConsumer.Start(); #endregion #region application event subscriber init _ApplicationEventConsumer = MessageQueueFactory.CreateEventSubscriber("AppEvent", "AppEventSubscriber", Environment.MachineName, new[] { "ApplicationEventSubscriber" }); _ApplicationEventConsumer.Start(); #endregion #region EventPublisher init _MessagePublisher = MessageQueueFactory.GetMessagePublisher(); _MessagePublisher.Start(); #endregion #region CommandBus init _CommandBus = MessageQueueFactory.GetCommandBus(); _CommandBus.Start(); #endregion } catch (Exception ex) { _Logger.Error(ex.GetBaseException().Message, ex); } }