Esempio n. 1
0
        public async Task ProcessQueue_SomeMessages_Produced()
        {
            await _outboxWriter.WriteAsync(
                new OutboundEnvelope <TestEventOne>(
                    new TestEventOne {
                Content = "Test"
            },
                    null,
                    new TestProducerEndpoint("topic1")));

            await _outboxWriter.WriteAsync(
                new OutboundEnvelope <TestEventTwo>(
                    new TestEventTwo {
                Content = "Test"
            },
                    null,
                    new TestProducerEndpoint("topic2")));

            await _outboxWriter.CommitAsync();

            await _worker.ProcessQueueAsync(CancellationToken.None);

            _broker.ProducedMessages.Should().HaveCount(2);
            _broker.ProducedMessages[0].Endpoint.Name.Should().Be("topic1");
            _broker.ProducedMessages[1].Endpoint.Name.Should().Be("topic2");
        }
 /// <summary>
 ///     Calls the <see cref="IOutboxWorker" /> to process the queue at regular intervals.
 /// </summary>
 /// <inheritdoc cref="RecurringDistributedBackgroundService.ExecuteRecurringAsync" />
 protected override Task ExecuteRecurringAsync(CancellationToken stoppingToken) =>
 _outboxWorker.ProcessQueueAsync(stoppingToken);