Esempio n. 1
0
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            Calls.Add(DateTime.UtcNow);
            var deferralTestMessage = message as DeferralTestMessage;

            if (deferralTestMessage == null)
            {
                return;
            }
            if (Calls.Count <= deferralTestMessage.NumberOfTimesToDefer)
            {
                await context.Defer(TimeSpan.FromSeconds(3));
            }
            else if (Calls.Count - deferralTestMessage.NumberOfTimesToDefer <= deferralTestMessage.NumberOfTimesToAbandon)
            {
                await context.Abandon();
            }
            else
            {
                if (deferralTestMessage.Complete)
                {
                    await context.Complete();
                }
                else
                {
                    if (!_hasDeadLettered)
                    {
                        await context.DeadLetter("Deadlettering this message");

                        _hasDeadLettered = true;
                    }
                }
            }
        }
Esempio n. 2
0
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            Calls.Add(DateTime.Now);

            ExpectedIdFound = context.GetMessageId() == "1234";

            await context.Complete().ConfigureAwait(false);
        }
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            var ExpectedTenantId = "CDBFB8A7-FEFF-4559-BFFB-301A2CB4E0BE";

            ExpectedTenantIdFound = ExpectedTenantId.Equals(context.GetTenantId(), StringComparison.InvariantCultureIgnoreCase);
            Calls.Add(DateTime.Now);
            await context.Complete().ConfigureAwait(false);
        }
Esempio n. 4
0
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            var testMessage = message as TestMessage1;

            ExpectedContentFound = testMessage.TestProperty == "巴黎";

            Calls.Add(DateTime.Now);
            await context.Complete().ConfigureAwait(false);
        }
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            Calls.Add(DateTime.UtcNow);

            if (Calls.Count > 1)
            {
                await context.Complete();

                return;
            }
            var textMessage1 = (TestMessage1)message;
            var sender       = context.CreateTransactionalSender(textMessage1.TestProperty);
            await sender.Send(new TestMessage2());

            throw new Exception("something went wrong");
        }
Esempio n. 6
0
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            var testMessage = message as TestMessage1;

            Calls.Add(DateTime.UtcNow);

            using (var connection = new NpgsqlConnection("Server=localhost;Port=6000;User Id=postgres;Password=test;Database=postgres"))
            {
                connection.Open();

                using (var tx = connection.BeginTransaction())
                {
                    tx?.Commit();
                }
            }

            await context.Complete();

            CommittedTransactions.Add(DateTime.UtcNow);
        }
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            Calls.Add(DateTime.UtcNow);

            await context.Complete();
        }
Esempio n. 8
0
        public async Task HandleMessage(object message, IMessageProcessingContext context)
        {
            Calls.Add(DateTime.Now);

            await context.Complete().ConfigureAwait(false);
        }