Batch remove message from Redis stream
This commit is contained in:
parent
6b6467c1d4
commit
1a8fa0b213
|
|
@ -190,7 +190,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Aspects.Cache" Version="2.0.4" />
|
||||
<PackageReference Include="DistributedLock.Redis" Version="1.0.3" />
|
||||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="8.7.1" />
|
||||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="8.8.0" />
|
||||
<PackageReference Include="Fluid.Core" Version="2.11.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
|
||||
|
|
|
|||
|
|
@ -180,20 +180,7 @@ public class RedisPublisher : IEventPublisher
|
|||
var db = _redis.GetDatabase();
|
||||
|
||||
var entries = await db.StreamRangeAsync(channel, "-", "+", count: count, messageOrder: Order.Ascending);
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
_logger.LogInformation($"Fetched message: {channel} {entry.Values[0].Value} ({entry.Id})");
|
||||
|
||||
try
|
||||
{
|
||||
await db.StreamDeleteAsync(channel, [entry.Id]);
|
||||
|
||||
_logger.LogWarning($"Deleted message: {channel} {entry.Values[0].Value} ({entry.Id})");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"Error processing message: {ex.Message}, event id: {channel} {entry.Id}\r\n{ex}");
|
||||
}
|
||||
}
|
||||
var deletedCount = await db.StreamDeleteAsync(channel, entries.Select(x => x.Id).ToArray());
|
||||
_logger.LogWarning($"Deleted {deletedCount} messages from Redis stream {channel}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,8 @@ public class RedisSubscriber : IEventSubscriber
|
|||
}
|
||||
finally
|
||||
{
|
||||
await db.StreamDeleteAsync(channel, [entry.Id]);
|
||||
var deletedCount = await db.StreamDeleteAsync(channel, [entry.Id]);
|
||||
_logger.LogInformation($"Handled message {entry.Id}: {deletedCount == 1}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,6 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
using BotSharp.Abstraction.Agents.Enums;
|
||||
using BotSharp.Abstraction.Messaging.Enums;
|
||||
using BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||
using BotSharp.Abstraction.Messaging;
|
||||
using BotSharp.Abstraction.Planning;
|
||||
using BotSharp.Abstraction.Routing;
|
||||
using BotSharp.Core.Infrastructures;
|
||||
using System.Text.RegularExpressions;
|
||||
using BotSharp.Plugin.SqlDriver.Interfaces;
|
||||
|
||||
namespace BotSharp.Plugin.SqlDriver.Hooks;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using SQLitePCL;
|
||||
|
||||
namespace BotSharp.Plugin.WebDriver.Functions;
|
||||
|
||||
public class OpenBrowserFn : IFunctionCallback
|
||||
|
|
|
|||
Loading…
Reference in a new issue