Ends in:
4 DAYS
9 HRS
57 MIN
27 SEC
Ends in:
4 D
9 H
57 M
27 S
Open Closed

Update IncomingEventInfo Extra Properties #7293


User avatar
0
mariovh created

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 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team 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 v9.1.0-preview. Updated on December 02, 2024, 12:35