mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
catch any unhandled exceptions in event processor
This commit is contained in:
parent
242e509b9d
commit
ba2c7fe67d
@ -71,18 +71,26 @@ namespace Bit.EventsProcessor
|
||||
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var messages = await _queue.GetMessagesAsync(32, TimeSpan.FromMinutes(1),
|
||||
null, null, cancellationToken);
|
||||
if(messages.Any())
|
||||
try
|
||||
{
|
||||
foreach(var message in messages)
|
||||
var messages = await _queue.GetMessagesAsync(32, TimeSpan.FromMinutes(1),
|
||||
null, null, cancellationToken);
|
||||
if(messages.Any())
|
||||
{
|
||||
await ProcessQueueMessageAsync(message.AsString, cancellationToken);
|
||||
await _queue.DeleteMessageAsync(message);
|
||||
foreach(var message in messages)
|
||||
{
|
||||
await ProcessQueueMessageAsync(message.AsString, cancellationToken);
|
||||
await _queue.DeleteMessageAsync(message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch(Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Exception occurred: " + e.Message);
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
||||
}
|
||||
}
|
||||
@ -124,11 +132,6 @@ namespace Bit.EventsProcessor
|
||||
{
|
||||
_logger.LogError("JsonSerializationException: Unable to serialize token.");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Exception occurred. " + e.Message);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user