Skip to content
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

Audit queue incorrectly created on send-only endpoint #6740

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ public async Task Should_create_queues_when_installers_enabled()
Assert.IsTrue(context.SetupInfrastructure);
}

[Test]
public async Task Should_not_create_when_sendonly()
{
var suffix = Guid.NewGuid().ToString().Substring(0, 8);
var errorQueueName = "error-" + suffix;
var auditQueueName = "audit-" + suffix;

var context = await Scenario.Define<Context>(c =>
{
c.EnableInstallers = true;
})
.WithEndpoint<Endpoint>(e => e.CustomConfig(endpointConfig =>
{
endpointConfig.SendOnly();
endpointConfig.SendFailedMessagesTo(errorQueueName);
endpointConfig.AuditProcessedMessagesTo(auditQueueName);
}))
.Done(c => c.EndpointsStarted)
.Run();

Assert.IsTrue(context.SetupInfrastructure);

CollectionAssert.DoesNotContain(context.SendingAddresses, errorQueueName);
CollectionAssert.DoesNotContain(context.SendingAddresses, auditQueueName);
}

[Test]
public async Task Should_pass_receive_and_send_queue_addresses()
{
Expand Down
2 changes: 2 additions & 0 deletions src/NServiceBus.Core/Audit/Audit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ internal Audit()
settings.Set(AuditConfigReader.GetConfiguredAuditQueue(settings));
});
Prerequisite(config => config.Settings.GetOrDefault<AuditConfigReader.Result>() != null, "No configured audit queue was found");
Prerequisite(context => !context.Settings.GetOrDefault<bool>("Endpoint.SendOnly"),
"Auditing is only relevant for endpoints receiving messages.");
}


Expand Down