/// <summary> /// Initializes a new instance of the <see cref="OutboxWorkerService" /> class. /// </summary> /// <param name="interval"> /// The interval between each execution. /// </param> /// <param name="outboxWorker"> /// The <see cref="IOutboxWorker" /> implementation. /// </param> /// <param name="distributedLockSettings"> /// Customizes the lock mechanism settings. /// </param> /// <param name="distributedLockManager"> /// The <see cref="IDistributedLockManager" />. /// </param> /// <param name="logger"> /// The <see cref="ISilverbackLogger" />. /// </param> public OutboxWorkerService( TimeSpan interval, IOutboxWorker outboxWorker, DistributedLockSettings distributedLockSettings, IDistributedLockManager distributedLockManager, ISilverbackLogger <OutboxWorkerService> logger) : base(interval, distributedLockSettings, distributedLockManager, logger) { _outboxWorker = outboxWorker; }
public OutboxWorkerTests() { var serviceProvider = ServiceProviderHelper.GetServiceProvider( services => services .AddFakeLogger() .AddSilverback() .WithConnectionToMessageBroker( options => options .AddBroker <TestBroker>() .AddOutbox <InMemoryOutbox>() .AddOutboxWorker()) .AddEndpoints( endpoints => endpoints .AddOutbound <TestEventOne>(new TestProducerEndpoint("topic1")) .AddOutbound <TestEventTwo>(new TestProducerEndpoint("topic2")) .AddOutbound <TestEventThree>(new TestProducerEndpoint("topic3a")) .AddOutbound <TestEventThree>(new TestProducerEndpoint("topic3b")))); _broker = serviceProvider.GetRequiredService <TestBroker>(); _broker.ConnectAsync().Wait(); _worker = serviceProvider.GetRequiredService <IOutboxWorker>(); _outboxWriter = serviceProvider.GetRequiredService <IOutboxWriter>(); _sampleOutboundEnvelope = new OutboundEnvelope <TestEventOne>( new TestEventOne { Content = "Test" }, null, new TestProducerEndpoint("topic1")); _sampleOutboundEnvelope.RawMessage = AsyncHelper.RunValueTaskSynchronously( () => new JsonMessageSerializer().SerializeAsync( _sampleOutboundEnvelope.Message, _sampleOutboundEnvelope.Headers, MessageSerializationContext.Empty)); }