示例#1
0
        public void BatchDispatchUnackRmqTest()
        {
            var handler          = new EventHandlerWithBatchSupport(1);
            var endpointProvider = new Mock <IEndpointProvider>();

            using (
                var messagingEngine =
                    new MessagingEngine(
                        _logFactory,
                        new TransportResolver(new Dictionary <string, TransportInfo>
            {
                { "RabbitMq", new TransportInfo("amqp://localhost", "guest", "guest", null, "RabbitMq") }
            }), new RabbitMqTransportFactory(_logFactory)))
            {
                messagingEngine.CreateTemporaryDestination("RabbitMq", null);

                var endpoint = new Endpoint("RabbitMq", "testExchange", "testQueue", true, SerializationFormat.Json);
                endpointProvider.Setup(r => r.Get("route")).Returns(endpoint);
                endpointProvider.Setup(r => r.Contains("route")).Returns(true);

                using (var engine = new CqrsEngine(
                           _logFactory,
                           new DefaultDependencyResolver(),
                           messagingEngine,
                           endpointProvider.Object,
                           false,
                           Register.BoundedContext("bc")
                           .ListeningEvents(typeof(DateTime)).From("other").On("route")
                           .WithProjection(handler, "other", 1, 0,
                                           h => h.OnBatchStart(),
                                           (h, c) => h.OnBatchFinish(c)
                                           )))
                {
                    engine.StartSubscribers();
                    messagingEngine.Send(DateTime.Now, endpoint);
                    Thread.Sleep(20000);
                }
            }
        }