Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local message retry optimization #5

Closed
zhenlei520 opened this issue Feb 18, 2022 · 0 comments · Fixed by #10
Closed

Local message retry optimization #5

zhenlei520 opened this issue Feb 18, 2022 · 0 comments · Fixed by #10
Assignees
Labels
enhancement New feature or request

Comments

@zhenlei520
Copy link
Contributor

Local messages need to increase the last execution time to avoid repeated execution of messages

public async Task<IEnumerable<IntegrationEventLog>> RetrieveEventLogsFailedToPublishAsync(int retryBatchSize = 200, int maxRetryTimes = 10)
{
    var result = await _eventLogContext.EventLogs
        .Where(e => (e.State == IntegrationEventStates.PublishedFailed || e.State == IntegrationEventStates.InProgress) &&
            e.TimesSent <= maxRetryTimes)
        .OrderBy(o => o.CreationTime)
        .Take(retryBatchSize)
        .ToListAsync();

    if (result.Any())
    {
        _eventTypes ??= _serviceProvider.GetRequiredService<IIntegrationEventBus>().GetAllEventTypes()
            .Where(type => typeof(IIntegrationEvent).IsAssignableFrom(type));

        return result.OrderBy(o => o.CreationTime)
            .Select(e => e.DeserializeJsonContent(_eventTypes.First(t => t.Name == e.EventTypeShortName)));
    }

    return result;
}
@zhenlei520 zhenlei520 added the enhancement New feature or request label Feb 18, 2022
@zhenlei520 zhenlei520 self-assigned this Feb 18, 2022
@zhenlei520 zhenlei520 linked a pull request Feb 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant