-
Notifications
You must be signed in to change notification settings - Fork 21
Add Dead Letter Queue support to the consumer pipeline #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6779b6
Implement dead letter queue functionality for message handling
nabisobhi 3c00d05
Prevent dead lettering when cancellation is requested during message …
nabisobhi 58fbb37
Enhance topic name resolution to include group ID for dead letter queue
nabisobhi b7dd135
Fix typo in MessageResult documentation
nabisobhi 0e98625
Implement IDisposable for Consumer and DeadLetterQueueSpy to ensure p…
nabisobhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,78 +1,84 @@ | ||
| using Dafda.Consuming; | ||
| namespace Dafda.Tests.Builders; | ||
|
|
||
| using Dafda.Consuming; | ||
| using Dafda.Consuming.MessageFilters; | ||
| using Dafda.Tests.TestDoubles; | ||
| using TestDoubles; | ||
|
|
||
| namespace Dafda.Tests.Builders | ||
| internal class ConsumerBuilder | ||
| { | ||
| internal class ConsumerBuilder | ||
| private IHandlerUnitOfWorkFactory _unitOfWorkFactory = new HandlerUnitOfWorkFactoryStub(null); | ||
| private IConsumerScopeFactory _consumerScopeFactory = new ConsumerScopeFactoryStub(new ConsumerScopeStub(new MessageResultBuilder().Build())); | ||
| private MessageHandlerRegistry _registry = new(); | ||
| private IUnconfiguredMessageHandlingStrategy _unconfiguredMessageStrategy = new RequireExplicitHandlers(); | ||
| private readonly IMessageHandlerExecutionStrategy _messageHandlerExecutionStrategy = new DirectMessageHandlerExecutionStrategy(); | ||
|
|
||
| private bool _enableAutoCommit; | ||
| private MessageFilter _messageFilter = MessageFilter.Default; | ||
| private IDeadLetterQueue _deadLetterQueue = NullDeadLetterQueue.Instance; | ||
| private int _maxRetries; | ||
|
|
||
| public ConsumerBuilder WithUnitOfWork(IHandlerUnitOfWork unitOfWork) | ||
| { | ||
| private IHandlerUnitOfWorkFactory _unitOfWorkFactory; | ||
| private IConsumerScopeFactory _consumerScopeFactory; | ||
| private MessageHandlerRegistry _registry; | ||
| private IUnconfiguredMessageHandlingStrategy _unconfiguredMessageStrategy; | ||
| private IMessageHandlerExecutionStrategy _messageHandlerExecutionStrategy; | ||
|
|
||
| private bool _enableAutoCommit; | ||
| private MessageFilter _messageFilter = MessageFilter.Default; | ||
|
|
||
| public ConsumerBuilder() | ||
| { | ||
| _unitOfWorkFactory = new HandlerUnitOfWorkFactoryStub(null); | ||
| _consumerScopeFactory = new ConsumerScopeFactoryStub(new ConsumerScopeStub(new MessageResultBuilder().Build())); | ||
| _registry = new MessageHandlerRegistry(); | ||
| _unconfiguredMessageStrategy = new RequireExplicitHandlers(); | ||
| _messageHandlerExecutionStrategy = new DirectMessageHandlerExecutionStrategy(); | ||
| } | ||
| return WithUnitOfWorkFactory(new HandlerUnitOfWorkFactoryStub(unitOfWork)); | ||
| } | ||
|
|
||
| public ConsumerBuilder WithUnitOfWork(IHandlerUnitOfWork unitOfWork) | ||
| { | ||
| return WithUnitOfWorkFactory(new HandlerUnitOfWorkFactoryStub(unitOfWork)); | ||
| } | ||
| public ConsumerBuilder WithUnitOfWorkFactory(IHandlerUnitOfWorkFactory unitofWorkFactory) | ||
| { | ||
| _unitOfWorkFactory = unitofWorkFactory; | ||
| return this; | ||
| } | ||
|
|
||
| public ConsumerBuilder WithUnitOfWorkFactory(IHandlerUnitOfWorkFactory unitofWorkFactory) | ||
| { | ||
| _unitOfWorkFactory = unitofWorkFactory; | ||
| return this; | ||
| } | ||
| public ConsumerBuilder WithConsumerScopeFactory(IConsumerScopeFactory consumerScopeFactory) | ||
| { | ||
| _consumerScopeFactory = consumerScopeFactory; | ||
| return this; | ||
| } | ||
|
|
||
| public ConsumerBuilder WithConsumerScopeFactory(IConsumerScopeFactory consumerScopeFactory) | ||
| { | ||
| _consumerScopeFactory = consumerScopeFactory; | ||
| return this; | ||
| } | ||
| public ConsumerBuilder WithMessageHandlerRegistry(MessageHandlerRegistry registry) | ||
| { | ||
| _registry = registry; | ||
| return this; | ||
| } | ||
|
|
||
| public ConsumerBuilder WithMessageHandlerRegistry(MessageHandlerRegistry registry) | ||
| { | ||
| _registry = registry; | ||
| return this; | ||
| } | ||
| public ConsumerBuilder WithEnableAutoCommit(bool enableAutoCommit) | ||
| { | ||
| _enableAutoCommit = enableAutoCommit; | ||
| return this; | ||
| } | ||
|
|
||
| public ConsumerBuilder WithEnableAutoCommit(bool enableAutoCommit) | ||
| { | ||
| _enableAutoCommit = enableAutoCommit; | ||
| return this; | ||
| } | ||
| public void WithMessageFilter(MessageFilter messageFilter) | ||
| { | ||
| _messageFilter = messageFilter; | ||
| } | ||
|
|
||
| public void WithMessageFilter(MessageFilter messageFilter) | ||
| { | ||
| _messageFilter = messageFilter; | ||
| } | ||
| public ConsumerBuilder WithUnconfiguredMessageStrategy( | ||
| IUnconfiguredMessageHandlingStrategy strategy) | ||
| { | ||
| _unconfiguredMessageStrategy = strategy; | ||
| return this; | ||
| } | ||
|
|
||
| public ConsumerBuilder WithUnconfiguredMessageStrategy( | ||
| IUnconfiguredMessageHandlingStrategy strategy) | ||
| { | ||
| _unconfiguredMessageStrategy = strategy; | ||
| return this; | ||
| } | ||
| public ConsumerBuilder WithDeadLetterQueue(IDeadLetterQueue deadLetterQueue) | ||
| { | ||
| _deadLetterQueue = deadLetterQueue; | ||
| return this; | ||
| } | ||
|
|
||
| public Consumer Build() => | ||
| new Consumer( | ||
| _registry, | ||
| _unitOfWorkFactory, | ||
| _consumerScopeFactory, | ||
| _unconfiguredMessageStrategy, | ||
| _messageFilter, | ||
| _messageHandlerExecutionStrategy, | ||
| _enableAutoCommit); | ||
| public ConsumerBuilder WithMaxRetries(int maxRetries) | ||
| { | ||
| _maxRetries = maxRetries; | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| public Consumer Build() => | ||
| new Consumer( | ||
| _registry, | ||
| _unitOfWorkFactory, | ||
| _consumerScopeFactory, | ||
| _unconfiguredMessageStrategy, | ||
| _messageFilter, | ||
| _messageHandlerExecutionStrategy, | ||
| _enableAutoCommit, | ||
| _deadLetterQueue, | ||
| _maxRetries); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.