protected override void Load(ContainerBuilder builder) { builder.RegisterType <BoundedContextListener>().As <IBoundedContextListener>().SingleInstance(); var environmentVariables = Environment.GetEnvironmentVariables(); var kafkaSendTopics = new string[0]; if (environmentVariables.Contains(KAFKA_BOUNDED_CONTEXT_SEND_TOPICS)) { kafkaSendTopics = ((string)environmentVariables[KAFKA_BOUNDED_CONTEXT_SEND_TOPICS]).Split(';'); } var committedEventStreamSenderConfiguration = new CommittedEventStreamSenderConfiguration(kafkaSendTopics.Select(_ => (Topic)_)); builder.RegisterInstance(committedEventStreamSenderConfiguration).As <CommittedEventStreamSenderConfiguration>(); Topic topic = ""; if (environmentVariables.Contains(KAFKA_BOUNDED_CONTEXT_TOPIC)) { topic = (string)environmentVariables[KAFKA_BOUNDED_CONTEXT_TOPIC]; } var boundedContextListenerConfiguration = new BoundedContextListenerConfiguration(topic); builder.RegisterInstance(boundedContextListenerConfiguration).As <BoundedContextListenerConfiguration>(); }
public BoundedContextListener( BoundedContextListenerConfiguration configuration, IEventConverter eventConverter, IUncommittedEventStreamCoordinator uncommittedEventStreamCoordinator, ILogger logger, IApplicationResourceIdentifierConverter applicationResourceIdentifierConverter, IImplementationsOf <IEvent> eventTypes, IEventStore eventStore, IEventEnvelopes eventEnvelopes, IEventSequenceNumbers eventSequenceNumbers, IEventSourceVersions eventSourceVersions, ICommittedEventStreamBridge committedEventStreamBridge, IConsumer consumer) { _eventConverter = eventConverter; _uncommittedEventStreamCoordinator = uncommittedEventStreamCoordinator; _logger = logger; _applicationResourceIdentifierConverter = applicationResourceIdentifierConverter; _eventTypes = eventTypes; _eventSequenceNumbers = eventSequenceNumbers; _eventStore = eventStore; _eventEnvelopes = eventEnvelopes; _eventSourceVersions = eventSourceVersions; _committedEventStreamBridge = committedEventStreamBridge; _consumer = consumer; _serializer = new JsonSerializer(); _configuration = configuration; }