Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnusSandgren committed Oct 11, 2024
1 parent 6ec1aa6 commit 15ecc6e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ public interface IIdempotentNotificationContext

public readonly record struct NotificationAcknowledgementPart(string NotificationHandler, Guid EventId);

internal sealed class IdempotentNotificationHandler<TNotification>(
INotificationHandler<TNotification> decorated,
IIdempotentNotificationContext repository) :
internal sealed class IdempotentNotificationHandler<TNotification> :
INotificationHandler<TNotification>,
// We need to manually register this NotificationHandler because
// it should decorate all INotificationHandler<TNotification>
// instances, not be a notification handler in of itself.
IIgnoreOnAssemblyScan
where TNotification : IDomainEvent
{
private readonly INotificationHandler<TNotification> _decorated = decorated ?? throw new ArgumentNullException(nameof(decorated));
private readonly IIdempotentNotificationContext _repository = repository ?? throw new ArgumentNullException(nameof(repository));
private readonly INotificationHandler<TNotification> _decorated;
private readonly IIdempotentNotificationContext _repository;

public IdempotentNotificationHandler(INotificationHandler<TNotification> decorated, IIdempotentNotificationContext repository)
{
_decorated = decorated ?? throw new ArgumentNullException(nameof(decorated));
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
}

public async Task Handle(TNotification notification, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.AddTransactionalOutboxEntities(builder =>
{
builder.ToTable($"MassTransit{builder.Metadata.GetTableName()}");
// We can remove the code below when the following commit is in a MassTransit release we are using.
// https://github.com/MassTransit/MassTransit/commit/755b267a53c3e5fcdc9dcc0bbfda68a70aaf6bf4
if (builder is not EntityTypeBuilder<OutboxMessage> outboxMessageBuilder)
{
return;
Expand Down
4 changes: 1 addition & 3 deletions src/Digdir.Domain.Dialogporten.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
static void BuildAndRun(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseDefaultServiceProvider(options => options.ValidateScopes = false);

builder.Host.UseSerilog((context, services, configuration) => configuration
.MinimumLevel.Warning()
.ReadFrom.Configuration(context.Configuration)
Expand Down Expand Up @@ -139,8 +139,6 @@ static void BuildAndRun(string[] args)
predicate: localDevelopmentSettings.DisableAuth)
.ReplaceSingleton<ITokenIssuerCache, DevelopmentTokenIssuerCache>(
predicate: localDevelopmentSettings.DisableAuth);
// .AddHostedService<
// OutboxScheduler>(predicate: !localDevelopmentSettings.DisableShortCircuitOutboxDispatcher);
}

var app = builder.Build();
Expand Down

0 comments on commit 15ecc6e

Please sign in to comment.