Пример #1
0
        public Consumer()
        {
            _messageHandlerInvokerCache = new MessageHandlerInvokerCache();

            _rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();

            _rabbitMqBus.SubscribeToExchange(new RabbitMqEventSubscription <TestEventOne>("testevent-exchange", "topic", onMessage: (ev) =>
            {
                var candidateHandler = _messageHandlerInvokerCache.GetMethodInfo(GetType(), typeof(TestEventOne));

                if (null != candidateHandler)
                {
                    ((Task)candidateHandler.Invoke(this, new object[] { ev.Content })).Wait();
                }

                return(Task.CompletedTask);
            },
                                                                                          isExchangeDurable: false,
                                                                                          isExchangeAutoDelete: true,
                                                                                          isQueueDurable: false,
                                                                                          isQueueAutoAck: false,
                                                                                          isQueueAutoDelete: true,
                                                                                          isQueueExclusive: true,
                                                                                          routingStrategy: (ev) => ev.FilterOne == "filterOne"));
        }
Пример #2
0
        public async Task ShouldCreateAQueueAndPushMessageAndPullMessage()
        {
            var rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();

            var testExchangeName = $"test-exchange-{Guid.NewGuid()}";
            var testQueueName    = $"test-queue-{Guid.NewGuid()}";

            var testQueue = rabbitMqBus.RabbitMqConnection.DoWithChannel((channel) =>
                                                                         channel.QueueDeclare(testQueueName, exclusive: true, autoDelete: true).QueueName);

            rabbitMqBus.RabbitMqConnection.DoWithChannel((channel) =>
                                                         channel.ExchangeDeclare(testExchangeName, type: "x-delayed-message", durable: false, autoDelete: true, new Dictionary <string, object>()
            {
                { "x-delayed-type", "topic" }
            }));

            rabbitMqBus.RabbitMqConnection.DoWithChannel((channel) =>
                                                         channel.QueueBind(testQueueName, testExchangeName, "TestEventOne.#"));

            rabbitMqBus.Emit(new TestEventOne(Guid.NewGuid(), Guid.NewGuid()),
                             testExchangeName,
                             isMessagePersistent: false);

            await Task.Delay(100);

            var events = rabbitMqBus.Pull(testQueueName, true, 1);

            Assert.AreEqual(1, events.Length);
        }
        public void SetUp()
        {
            _rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();

            _counterTestEventOneNoFilter = 0;
            _counterTestEventTwoNoFilter = 0;

            _counterTestEventOneFilterOnFilterOne = 0;
            _counterTestEventTwoFilterOnFilterTwo = 0;
        }
        public TestMarketDataChangedActorRegistry()
        {
            var rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();

            For <IRabbitMqBus>().Use(rabbitMqBus);
        }
Пример #5
0
 public void SetUp()
 {
     _rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();
 }
Пример #6
0
        public TestSingleQueueMqActorRegistry()
        {
            var rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();

            For <IRabbitMqBus>().Use(rabbitMqBus);
        }
        public TestWorkerActorRegistry()
        {
            var rabbitMqBus = IntegrationTestsHelper.GetRabbitMqBus();

            For <IRabbitMqBus>().Use(rabbitMqBus);
        }