mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 01:36:30 +00:00
log queue errors
This commit is contained in:
@@ -13,6 +13,7 @@ using LinqToDB;
|
|||||||
using LinqToDB.Data;
|
using LinqToDB.Data;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RabbitMQ.Stream.Client;
|
using RabbitMQ.Stream.Client;
|
||||||
@@ -27,6 +28,7 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
private readonly IGalleryService _galleryService;
|
private readonly IGalleryService _galleryService;
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
private readonly IAzaionApi _api;
|
private readonly IAzaionApi _api;
|
||||||
|
private readonly ILogger<AnnotationService> _logger;
|
||||||
private readonly QueueConfig _queueConfig;
|
private readonly QueueConfig _queueConfig;
|
||||||
private Consumer _consumer = null!;
|
private Consumer _consumer = null!;
|
||||||
private readonly UIConfig _uiConfig;
|
private readonly UIConfig _uiConfig;
|
||||||
@@ -42,13 +44,15 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
IOptions<DirectoriesConfig> directoriesConfig,
|
IOptions<DirectoriesConfig> directoriesConfig,
|
||||||
IGalleryService galleryService,
|
IGalleryService galleryService,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IAzaionApi api)
|
IAzaionApi api,
|
||||||
|
ILogger<AnnotationService> logger)
|
||||||
{
|
{
|
||||||
_dbFactory = dbFactory;
|
_dbFactory = dbFactory;
|
||||||
_producer = producer;
|
_producer = producer;
|
||||||
_galleryService = galleryService;
|
_galleryService = galleryService;
|
||||||
_mediator = mediator;
|
_mediator = mediator;
|
||||||
_api = api;
|
_api = api;
|
||||||
|
_logger = logger;
|
||||||
_queueConfig = queueConfig.Value;
|
_queueConfig = queueConfig.Value;
|
||||||
_uiConfig = uiConfig.Value;
|
_uiConfig = uiConfig.Value;
|
||||||
_dirConfig = directoriesConfig.Value;
|
_dirConfig = directoriesConfig.Value;
|
||||||
@@ -75,6 +79,8 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
Reference = _api.CurrentUser.Email,
|
Reference = _api.CurrentUser.Email,
|
||||||
OffsetSpec = new OffsetTypeOffset(offsets.AnnotationsOffset + 1),
|
OffsetSpec = new OffsetTypeOffset(offsets.AnnotationsOffset + 1),
|
||||||
MessageHandler = async (_, _, context, message) =>
|
MessageHandler = async (_, _, context, message) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var email = (string)message.ApplicationProperties[nameof(User.Email)]!;
|
var email = (string)message.ApplicationProperties[nameof(User.Email)]!;
|
||||||
if (email == _api.CurrentUser.Email) //Don't process messages by yourself
|
if (email == _api.CurrentUser.Email) //Don't process messages by yourself
|
||||||
@@ -111,6 +117,11 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}, SaveQueueOffsetTaskId, TimeSpan.FromSeconds(10), scheduleCallAfterCooldown: true);
|
}, SaveQueueOffsetTaskId, TimeSpan.FromSeconds(10), scheduleCallAfterCooldown: true);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user