Is it possible to pre-subscribe to events from an event stream? Something like the folllowing:
public sealed class BonusingEventBus : IEventBus
{
private readonly IDomainEventHandlerFactory _eventHandlerBuilder;
private IDictionary<Type, EventHandlerInvoker> _eventHandlerInvokers;
public BonusingEventBus(IEnumerable eventHandlerTypes, IDomainEventHandlerFactory eventHandlerBuilder)
{
_eventHandlerBuilder = eventHandlerBuilder;
BuildEventInvokers(eventHandlerTypes);
}
public void PublishEvent(DomainEvent domainEvent)
{
var domainEventType = domainEvent.GetType();
**List invokers = **
**(from eventHandlerInvoker in _eventHandlerInvokers **
**where eventHandlerInvoker.Key.IsAssignableFrom(domainEventType) **
select eventHandlerInvoker.Value).ToList();
invokers.ForEach(i => i.Publish(domainEvent));
}
I basically want to move all subscription code to the beginning of the program so that I do not want other developers to specifically subscribe to events. I am currently doing this with an in-memory event bus and was wondering if this was possible using the event store. Basically use the event store as a bus and persist the events too.
-Arun