Provides uniform implementation of the (incoming filter) message deduplication for all the different types of filters with various persistence mechanisms.
        public bool Process(Envelope envelope)
        {
            if (null == _incomingFilter)
            {
                _incomingFilter = new IncomingFilter(new MessageDeduplicationPersistorMongoDbSsl());
            }

            return(_incomingFilter.Process(envelope));
        }
        public void ShouldProcessNewMessageWhenRedeliveredFlagIsNotSet()
        {
            // Arrange
            var incomingFilter = new IncomingFilter(_persistor.Object);
            var envelope = new Envelope();
            envelope.Headers = new Dictionary<string, object>();

            // Act
            var result = incomingFilter.Process(envelope);

            // Assert
            Assert.True(result);
        }
        public void ShouldProcessNewMessageWhenRedeliveredFlagIsSet()
        {
            // Arrange
            var incomingFilter = new IncomingFilter(_persistor.Object);
            Guid messageId = Guid.NewGuid();
            var envelope = new Envelope();
            envelope.Headers = new Dictionary<string, object> { { "Redelivered", true }, { "MessageId",  Encoding.ASCII.GetBytes(messageId.ToString()) } };

            // Act
            var result = incomingFilter.Process(envelope);

            // Assert
            Assert.True(result);
        }
        public void ShouldNotProcessDuplicateMessageWhenRedeliveredFlagIsSet()
        {
            // Arrange
            Guid messageId = Guid.NewGuid();
            _persistor.Setup(i => i.GetMessageExists(messageId)).Returns(true);
            var incomingFilter = new IncomingFilter(_persistor.Object);
            var envelope = new Envelope();
            envelope.Headers = new Dictionary<string, object> { { "Redelivered", true }, { "MessageId", Encoding.ASCII.GetBytes(messageId.ToString()) } };

            // Act
            var result = incomingFilter.Process(envelope);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 5
0
        public bool Process(Envelope envelope)
        {
            var incomingFilter = new IncomingFilter(new MessageDeduplicationPersistorInMemory());

            return(incomingFilter.Process(envelope));
        }
        public bool Process(Envelope envelope)
        {
            var incomingFilter = new IncomingFilter(new MessageDeduplicationPersistorMongoDbSsl());

            return incomingFilter.Process(envelope);
        }
        public void ShouldRethrowAnyInternalException()
        {
            // Arrange
            Guid messageId = Guid.NewGuid();
            _persistor.Setup(i => i.GetMessageExists(messageId)).Throws(new Exception());
            var incomingFilter = new IncomingFilter(_persistor.Object);
            var envelope = new Envelope();
            envelope.Headers = new Dictionary<string, object> { { "Redelivered", true }, { "MessageId", Encoding.ASCII.GetBytes(messageId.ToString()) } };

            // Act / Assert
            Assert.Throws<Exception>(() => incomingFilter.Process(envelope));
        }