// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Reads the host machine which runs the RabbitMQ. var rabbitHost = this.Configuration["rabbit:host"]; // Reads the RabbitMQ exchange setting. var rabbitExchangeName = this.Configuration["rabbit:exchange"]; // Reads the name of the event queue. var rabbitEventQueueName = this.Configuration["rabbit:eventQueue"]; // Reads the name of the command queue. var rabbitCommandQueueName = this.Configuration["rabbit:commandQueue"]; var connectionFactory = new ConnectionFactory { HostName = rabbitHost }; var messageSerializer = new MessageJsonSerializer(); // Add framework services. services.AddMvc(); services.AddApworks() .WithCommandSender(new CommandBus(connectionFactory, messageSerializer, rabbitExchangeName, ExchangeType.Topic)) .WithCommandSubscriber(new CommandBus(connectionFactory, messageSerializer, rabbitExchangeName, ExchangeType.Topic, rabbitCommandQueueName)) .WithDefaultCommandConsumer("commands.*") .AddCommandHandler(new PostTextCommandHandler()) .WithEventSubscriber(new EventBus(connectionFactory, messageSerializer, rabbitExchangeName, ExchangeType.Topic, rabbitEventQueueName)) .WithDefaultEventConsumer("events.*") .AddEventHandler(new AccountCreatedEventHandler(this.Configuration)) .Configure(); var serviceProvider = services.BuildServiceProvider(); this.commandSender = serviceProvider.GetService <ICommandSender>(); this.eventConsumer = serviceProvider.GetService <IEventConsumer>(); this.eventConsumer.Consume(); this.commandConsumer = serviceProvider.GetService <ICommandConsumer>(); this.commandConsumer.Consume(); }
/// <summary> /// Initializes a new instance of the <see cref="Microservice"/> class. /// </summary> /// <param name="commandConsumer">The command consumer.</param> /// <param name="eventConsumer">The event consumer.</param> public Microservice(ICommandConsumer commandConsumer, IEventConsumer eventConsumer) { this.commandConsumer = commandConsumer; this.eventConsumer = eventConsumer; }
public AccountService(ICommandConsumer commandConsumer, IEventConsumer eventConsumer) : base(commandConsumer, eventConsumer) { }
public WhenSendingSwitchCommand(ITestOutputHelper testOutputHelper) { _commandConsumer = A.Fake <ICommandConsumer>(); _testDevice = new SwitchableLight(DeviceId, new TestLogger(testOutputHelper), new TestDataProvider(), new DataSourceFactory(), _commandConsumer, new CommandSinkFactory()); }
protected void AddCommandSink(string commandId, ICommandConsumer commandConsumer) { var commandSink = _commandSinkFactory.Create(GetCommandSinkId(Id, commandId), _logger, commandConsumer); _commandSinks.Add(commandSink); }
public CommandSink(string id, ILog logger, ICommandConsumer commandConsumer) { Id = id; _logger = logger; _commandConsumer = commandConsumer; }
public SwitchableLight(string id, ILog logger, IDataProvider dataProvider, IDataSourceFactory dataSourceFactory, ICommandConsumer commandConsumer, ICommandSinkFactory commandSinkFactory) : base(id, logger, dataSourceFactory, commandSinkFactory) { AddDataSource(StateDataId, dataProvider); AddCommandSink(SwitchCommandId, commandConsumer); }
public CommandConsumerAdapter(ICommandConsumer <TCommand> commandConsumer) { Guard.NotNull(commandConsumer, nameof(commandConsumer)); this.commandConsumer = commandConsumer; }
public InMemoryCommandProducer(ICommandConsumer consumer) { this.consumer = consumer; }
public SocialService(ICommandConsumer commandConsumer, IEventConsumer eventConsumer) : base(commandConsumer, eventConsumer) { }
public ICommandSink Create(string id, ILog logger, ICommandConsumer commandConsumer) { return(new CommandSink(id, logger, commandConsumer)); }
public TextingService(ICommandConsumer commandConsumer, IEventConsumer eventConsumer) : base(commandConsumer, eventConsumer) { }