Example #1
0
        private void ConfigureHandlers()
        {
            //Should get this from a config setting instead of hardcoding it.
            var redis       = ConnectionMultiplexer.Connect("localhost");
            var productView = new ProductView(new RedisReadModelRepository <ProductDto>(redis.GetDatabase()));

            ServiceLocator.ProductView = productView;

            IBaristaClient masterDataClient = new BaristaClient();

            var eventMappings = new EventHandlerDiscovery()
                                .Scan(productView)
                                .Handlers;

            var subscriptionName = "journeydesigner_readmodel";
            var topicFilter1     = "MasterData.Common.Events";
            var topicFilter2     = "Barista.Common.Events";

            var b = RabbitHutch.CreateBus("host=localhost");

            b.Subscribe <PublishedMessage>(subscriptionName,
                                           m =>
            {
                Aggregate handler;
                var messageType  = Type.GetType(m.MessageTypeName);
                var handlerFound = eventMappings.TryGetValue(messageType, out handler);
                if (handlerFound)
                {
                    var @event = JsonConvert.DeserializeObject(m.SerialisedMessage, messageType);
                    handler.AsDynamic().ApplyEvent(@event, ((Event)@event).Version);
                }
            },
                                           q => q.WithTopic(topicFilter1).WithTopic(topicFilter2));

            var bus = new RabbitMqBus(b);

            ServiceLocator.Bus = bus;
        }
Example #2
0
        private void ConfigureHandlers()
        {
            //Should get this from a config setting instead of hardcoding it.
            var redis = ConnectionMultiplexer.Connect("localhost");
            var productView = new ProductView(new RedisReadModelRepository<ProductDto>(redis.GetDatabase()));
            ServiceLocator.ProductView = productView;

            IBaristaClient masterDataClient = new BaristaClient();

            var eventMappings = new EventHandlerDiscovery()
                                .Scan(productView)
                                .Handlers;

            var subscriptionName = "journeydesigner_readmodel";
            var topicFilter1 = "MasterData.Common.Events";
            var topicFilter2 = "Barista.Common.Events";

            var b = RabbitHutch.CreateBus("host=localhost");

            b.Subscribe<PublishedMessage>(subscriptionName,
            m =>
            {
                Aggregate handler;
                var messageType = Type.GetType(m.MessageTypeName);
                var handlerFound = eventMappings.TryGetValue(messageType, out handler);
                if (handlerFound)
                {
                    var @event = JsonConvert.DeserializeObject(m.SerialisedMessage, messageType);
                    handler.AsDynamic().ApplyEvent(@event, ((Event)@event).Version);
                }
            },
            q => q.WithTopic(topicFilter1).WithTopic(topicFilter2));

            var bus = new RabbitMqBus(b);

            ServiceLocator.Bus = bus;
        }
Example #3
0
        private void LoadExternalData()
        {
            IBaristaClient masterDataClient = new BaristaClient();

            masterDataClient.Initialise();
        }