Avata Suljettu

Update IncomingEventInfo Extra Properties #7293


User avatar
0
mariovh luotu

ABP Framework version: v7.4.4 UI Type: Blazor WASM Database System: EF Core (SQL Server)

Hi, Im using Abp AzureDistributedEventBus, with outbox and inbox pattern, and i need to update IncomingEventInfo ExtraProperties when I MarkAsProcessedAsync. Here is my code:

internal async Task IncomingEventInfoMarkAsProcessed(IncomingEventInfo incomingEvent, InboxConfig inboxConfig)
{
    if (AbpDistributedEventBusOptions.Inboxes.Count <= 0)
    {
        return;
    }
    using var scope = ServiceScopeFactory.CreateScope();
    var eventInbox = (IEventInbox)scope.ServiceProvider.GetRequiredService(inboxConfig.ImplementationType);

    if (incomingEvent.MessageId.IsNullOrEmpty())
    {
        return;
    }

    if (!Guid.TryParse(incomingEvent.MessageId, out var messageId))
    {
        return;
    }

    if (!await eventInbox.ExistsByMessageIdAsync(incomingEvent.MessageId))
    {
        return;
    }
    incomingEvent.ExtraProperties.Add("ERROR COUNT", 1);
    // UPDATE DE EXTRA PROPERTIES
    await eventInbox.MarkAsProcessedAsync(messageId);
}

1 Vastaus (t)
  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    Hi,

    there is no IncomingEventInfo entity. You may want to update the IncomingEventRecord

    You can try:

    
    protected IDbContextProvider<YourDbContext> DbContextProvider { get; }
    
    internal async Task IncomingEventInfoMarkAsProcessed(IncomingEventInfo incomingEvent, InboxConfig inboxConfig)
    {
        .....
        var dbContext = await DbContextProvider.GetDbContextAsync();
        await dbContext.IncomingEvents.Where(x => x.Id == messageId).ExecuteUpdateAsync(....);
    
        await eventInbox.MarkAsProcessedAsync(messageId);
    }
    
Made with ❤️ on ABP v8.2.0-preview Updated on maaliskuuta 25, 2024, 15.11