don't let every single possible client explode just because one malformed message was seen
This commit is contained in:
parent
013e4079c3
commit
d79ba3671b
@ -37,24 +37,27 @@ namespace franz
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
var cr = topicConsumer.Consume();
|
||||
try{
|
||||
var deserialized = JsonConvert.DeserializeObject(cr.Message.Value, messageType);
|
||||
if (deserialized != null && (deserialized as gray_messages.message).type == deserialized.GetType().ToString())
|
||||
{
|
||||
foreach (var waitingAction in externalSubscribers)
|
||||
{
|
||||
try
|
||||
{
|
||||
waitingAction(deserialized);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(JsonSerializationException jse)
|
||||
{
|
||||
Console.Error.WriteLine($"couldn't deserialize {cr?.Message?.Value} as {messageType}; {jse}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.Error.WriteLine("if I don't catch this error the whole thing dies so...");
|
||||
Console.Error.WriteLine("something happened in an action handler for: ");
|
||||
Console.Error.WriteLine(JsonConvert.SerializeObject(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
topicConsumer.Close();
|
||||
|
Loading…
Reference in New Issue
Block a user