Skip to content

Commit

Permalink
Carael/message removal performance fix (#54)
Browse files Browse the repository at this point in the history
* Messages removal performance fix
* Moved down upload file limit to 200
  • Loading branch information
Carael authored Mar 13, 2024
1 parent a4220f4 commit 10c920d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/Core/ServiceBus/MessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using CrossBusExplorer.ServiceBus.Contracts;
using CrossBusExplorer.ServiceBus.Contracts.Types;
using CrossBusExplorer.ServiceBus.Mappings;
using Microsoft.Azure.Amqp.Serialization;
using SubQueue = CrossBusExplorer.ServiceBus.Contracts.Types.SubQueue;
namespace CrossBusExplorer.ServiceBus;

Expand Down Expand Up @@ -180,18 +181,32 @@ public async Task<Result> DeleteMessage(

try
{
await foreach (var message in receiver.ReceiveMessagesAsync(cancellationToken))
var messagesToUnlock = new List<ServiceBusReceivedMessage>();

await foreach (ServiceBusReceivedMessage message in receiver.ReceiveMessagesAsync(
cancellationToken))
{
if (message.SequenceNumber > sequenceNumber)
{
messagesToUnlock.Add(message);
break;
}

if (message.SequenceNumber == sequenceNumber)
{
await receiver.CompleteMessageAsync(message, cancellationToken);

messageCompleted = true;
break;
}
messagesToUnlock.Add(message);
}

foreach (ServiceBusReceivedMessage message in messagesToUnlock)
{
await receiver.AbandonMessageAsync(message, null, cancellationToken);
}

}
catch (TaskCanceledException)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Ui/Website/Shared/Messages/MessagesUploadDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<MudText Typo="Typo.h6">
Upload messages from file
</MudText>
<MudText>Max 1000 at once</MudText>
<MudText>Max 200 at once</MudText>
</TitleContent>
<DialogContent>
<MudPaper Elevation="3">
Expand All @@ -29,7 +29,7 @@
</MudPaper>
<MudPaper Elevation="3">
<MudField Variant="Variant.Outlined" Label="Select files">
<MudFileUpload T="IReadOnlyList<IBrowserFile>" FilesChanged="UploadFilesAsync" MaximumFileCount="1000">
<MudFileUpload T="IReadOnlyList<IBrowserFile>" FilesChanged="UploadFilesAsync" MaximumFileCount="200">
<ButtonTemplate>
<MudButton HtmlTag="label"
Variant="Variant.Filled"
Expand Down
1 change: 0 additions & 1 deletion src/Ui/Website/ViewModels/MessagesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public async Task Delete(Message message, SubQueue subQueue)
}
else
{
_snackbar.Add("Message successfully removed", Severity.Success);
Messages.Remove(message);
}
};
Expand Down

0 comments on commit 10c920d

Please sign in to comment.