mirror of
https://github.com/bitwarden/server.git
synced 2025-01-16 20:51:23 +01:00
some logging from queue service
This commit is contained in:
parent
53caacb870
commit
263dfda9c4
@ -60,26 +60,34 @@ namespace Bit.Notifications
|
|||||||
var queueClient = storageAccount.CreateCloudQueueClient();
|
var queueClient = storageAccount.CreateCloudQueueClient();
|
||||||
_queue = queueClient.GetQueueReference("notifications");
|
_queue = queueClient.GetQueueReference("notifications");
|
||||||
|
|
||||||
while(!cancellationToken.IsCancellationRequested)
|
_logger.LogInformation("starting queue read");
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var messages = await _queue.GetMessagesAsync(32, TimeSpan.FromMinutes(1),
|
while(!cancellationToken.IsCancellationRequested)
|
||||||
null, null, cancellationToken);
|
|
||||||
if(messages.Any())
|
|
||||||
{
|
{
|
||||||
foreach(var message in messages)
|
var messages = await _queue.GetMessagesAsync(32, TimeSpan.FromMinutes(1),
|
||||||
|
null, null, cancellationToken);
|
||||||
|
if(messages.Any())
|
||||||
{
|
{
|
||||||
var notificationJson = message.AsString;
|
foreach(var message in messages)
|
||||||
var notification = JsonConvert.DeserializeObject<PushNotificationData<object>>(
|
{
|
||||||
notificationJson);
|
var notificationJson = message.AsString;
|
||||||
await HubHelpers.SendNotificationToHubAsync(notification.Type, notificationJson,
|
var notification = JsonConvert.DeserializeObject<PushNotificationData<object>>(
|
||||||
_hubContext, cancellationToken);
|
notificationJson);
|
||||||
await _queue.DeleteMessageAsync(message);
|
await HubHelpers.SendNotificationToHubAsync(notification.Type, notificationJson,
|
||||||
|
_hubContext, cancellationToken);
|
||||||
|
await _queue.DeleteMessageAsync(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
catch(Exception e)
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
{
|
||||||
}
|
_logger.LogError(e, "error from queue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user