Ejemplo n.º 1
0
        private static IMessageBus BuildMessageBus(AbstractConfiguration cfg)
        {
            ISubscriptionService subscriptionService = MessageBusConfigurationExtensions.GetSubscriptionService(cfg);
            IMessageSink         messageSink         = MessageBusConfigurationExtensions.GetMessageSink(cfg);
            IObjectContainer     container           = ObjectContainerConfigurationExtensions.GetObjectContainer(cfg);
            IRouteManager        routeManager        = container.Resolve <IRouteManager>();

            Xyperico.Agres.MessageBus.Implementation.MessageBus bus = new Agres.MessageBus.Implementation.MessageBus(subscriptionService, routeManager, messageSink);
            container.RegisterInstance <IMessageBus>(bus);

            return(bus);
        }
Ejemplo n.º 2
0
        private static void AutoSubscribeToHandledMessages(BaseConfiguration cfg)
        {
            ISubscriptionService subscriptionService = MessageBusConfigurationExtensions.GetSubscriptionService(cfg);
            IMessageSink         messageSink         = MessageBusConfigurationExtensions.GetMessageSink(cfg);

            MessageDispatcher dispatcher = MessageBusConfigurationExtensions.GetDispatcher(cfg);

            foreach (Type msg in dispatcher.GetHandledMessages())
            {
                if (typeof(IEvent).IsAssignableFrom(msg))
                {
                    subscriptionService.Subscribe(msg, messageSink);
                }
            }
        }