Batch remove message from Redis stream
This commit is contained in:
parent
6b6467c1d4
commit
1a8fa0b213
|
|
@ -190,7 +190,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Aspects.Cache" Version="2.0.4" />
|
<PackageReference Include="Aspects.Cache" Version="2.0.4" />
|
||||||
<PackageReference Include="DistributedLock.Redis" Version="1.0.3" />
|
<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="Fluid.Core" Version="2.11.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" 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 db = _redis.GetDatabase();
|
||||||
|
|
||||||
var entries = await db.StreamRangeAsync(channel, "-", "+", count: count, messageOrder: Order.Ascending);
|
var entries = await db.StreamRangeAsync(channel, "-", "+", count: count, messageOrder: Order.Ascending);
|
||||||
foreach (var entry in entries)
|
var deletedCount = await db.StreamDeleteAsync(channel, entries.Select(x => x.Id).ToArray());
|
||||||
{
|
_logger.LogWarning($"Deleted {deletedCount} messages from Redis stream {channel}");
|
||||||
_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}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,8 @@ public class RedisSubscriber : IEventSubscriber
|
||||||
}
|
}
|
||||||
finally
|
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>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
using BotSharp.Abstraction.Agents.Enums;
|
|
||||||
using BotSharp.Abstraction.Messaging.Enums;
|
using BotSharp.Abstraction.Messaging.Enums;
|
||||||
using BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
using BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||||
using BotSharp.Abstraction.Messaging;
|
using BotSharp.Abstraction.Messaging;
|
||||||
using BotSharp.Abstraction.Planning;
|
using BotSharp.Abstraction.Planning;
|
||||||
using BotSharp.Abstraction.Routing;
|
|
||||||
using BotSharp.Core.Infrastructures;
|
using BotSharp.Core.Infrastructures;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using BotSharp.Plugin.SqlDriver.Interfaces;
|
|
||||||
|
|
||||||
namespace BotSharp.Plugin.SqlDriver.Hooks;
|
namespace BotSharp.Plugin.SqlDriver.Hooks;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
using SQLitePCL;
|
|
||||||
|
|
||||||
namespace BotSharp.Plugin.WebDriver.Functions;
|
namespace BotSharp.Plugin.WebDriver.Functions;
|
||||||
|
|
||||||
public class OpenBrowserFn : IFunctionCallback
|
public class OpenBrowserFn : IFunctionCallback
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue