Exemplo n.º 1
0
 public void Emit()
 {
     _rabbitMqBus.Emit(new TestEventOne(Guid.NewGuid(), Guid.NewGuid())
     {
         FilterOne = "filterOne"
     }, "testevent-exchange",
                       isMessageMandatory: false,
                       isMessagePersistent: false);
 }
Exemplo n.º 2
0
        public async Task ShouldSubmitMessageAndDelayIt()
        {
            _rabbitMqBus.Emit(new TestEventOne(Guid.NewGuid(), Guid.NewGuid())
            {
                FilterOne = "AnotherfilterOne"
            }, "testevent-exchange", initialVisibilityDelay:  TimeSpan.FromSeconds(3), isMessagePersistent: false);

            await Task.Delay(1000);

            Assert.AreEqual(0, _counter);

            await Task.Delay(2500);

            Assert.AreEqual(1, _counter);
        }
        public async Task ShouldEmitEventsAndConsumeThem()
        {
            _rabbitMqBus.Emit(new TestEventOne(Guid.NewGuid(), Guid.NewGuid())
            {
                FilterOne = "AnotherfilterOne"
            },
                              "testevent-exchange",
                              isMessageMandatory: false,
                              isMessagePersistent: false);

            await Task.Delay(500);

            Assert.AreEqual(0, _counterTestEventTwoNoFilter);
            Assert.AreEqual(0, _counterTestEventTwoFilterOnFilterTwo);
            Assert.AreEqual(1, _counterTestEventOneNoFilter);
            Assert.AreEqual(0, _counterTestEventOneFilterOnFilterOne);

            _rabbitMqBus.Emit(new TestEventOne(Guid.NewGuid(), Guid.NewGuid())
            {
                FilterOne = "filterOne"
            },
                              "testevent-exchange",
                              isMessageMandatory: false,
                              isMessagePersistent: false);

            await Task.Delay(500);

            Assert.AreEqual(0, _counterTestEventTwoNoFilter);
            Assert.AreEqual(0, _counterTestEventTwoFilterOnFilterTwo);
            Assert.AreEqual(2, _counterTestEventOneNoFilter);
            Assert.AreEqual(1, _counterTestEventOneFilterOnFilterOne);

            _rabbitMqBus.Emit(new TestEventTwo(Guid.NewGuid(), Guid.NewGuid())
            {
                FilterOne = "filterOne"
            },
                              "testevent-exchange",
                              isMessageMandatory: false,
                              isMessagePersistent: false);

            await Task.Delay(500);

            Assert.AreEqual(1, _counterTestEventTwoNoFilter);
            Assert.AreEqual(0, _counterTestEventTwoFilterOnFilterTwo);
            Assert.AreEqual(2, _counterTestEventOneNoFilter);
            Assert.AreEqual(1, _counterTestEventOneFilterOnFilterOne);

            _rabbitMqBus.Emit(new TestEventTwo(Guid.NewGuid(), Guid.NewGuid())
            {
                FilterTwo = "filterTwo"
            },
                              "testevent-exchange",
                              isMessageMandatory: false,
                              isMessagePersistent: false);

            await Task.Delay(500);

            Assert.AreEqual(2, _counterTestEventTwoNoFilter);
            Assert.AreEqual(1, _counterTestEventTwoFilterOnFilterTwo);
            Assert.AreEqual(2, _counterTestEventOneNoFilter);
            Assert.AreEqual(1, _counterTestEventOneFilterOnFilterOne);
        }