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

Slowing down the polling on database backed queue listeners in the ca… #1200

Merged
merged 1 commit into from
Jan 8, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/Persistence/PersistenceTests/durability_with_local.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ public async Task should_recover_persisted_messages()
// Don't use WolverineHost here because you need the existing persisted state!!!!
using var host2 = await Host.CreateDefaultBuilder().UseWolverine(opts => opts.ConfigureDurableSender(true, false))
.StartAsync();
var counts2 = await host2.Get<IMessageStore>().Admin.FetchCountsAsync();
var messageStore = host2.Get<IMessageStore>();
var counts2 = await messageStore.Admin.FetchCountsAsync();

var i = 0;
while (counts2.Incoming != 1 && i < 10)
while (counts2.Incoming != 1 && i < 100)
{
await Task.Delay(100.Milliseconds());
counts2 = await host2.Get<IMessageStore>().Admin.FetchCountsAsync();
counts2 = await messageStore.Admin.FetchCountsAsync();
i++;
}

Expand All @@ -61,7 +62,11 @@ public static void ConfigureDurableSender(this WolverineOptions opts, bool latch
.ToLocalQueue("one")
.UseDurableInbox();

opts.Services.AddMarten(Servers.PostgresConnectionString)
opts.Services.AddMarten(opts =>
{
opts.Connection(Servers.PostgresConnectionString);
opts.DisableNpgsqlLogging = true;
})
.IntegrateWithWolverine();

opts.Services.AddSingleton(new ReceivingSettings { Latched = latched });
Expand All @@ -85,7 +90,7 @@ public void Handle(ReceivedMessage message, Envelope envelope, ReceivingSettings

public static void Configure(HandlerChain chain)
{
chain.OnException(e => true).Requeue(1000);
chain.OnException(e => true).RequeueIndefinitely();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,13 @@ private async Task listenForMessagesAsync()
if (messages.Any())
{
await _receiver.ReceivedAsync(this, messages.ToArray());

await Task.Delay(250.Milliseconds());
}
else
{
// Slow down if this is a periodically used queue
await Task.Delay(250.Milliseconds());
await Task.Delay(_settings.ScheduledJobPollingTime);
}
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private async Task listenForMessagesAsync()
else
{
// Slow down if this is a periodically used queue
await Task.Delay(250.Milliseconds());
await Task.Delay(_settings.ScheduledJobPollingTime);
}
}
catch (Exception e)
Expand Down
Loading