private async Task HandleMessage(ConsumerRecord <byte[], byte[]> message) { var value = stringDeserializer.Deserialize(message.Topic, message.Value); var eventEnvelope = JsonConvert.DeserializeObject <EventEnvelope>(value, jsonSerializerSettingsProvider.GetJsonSerializerSettings()); if (eventEnvelope != null) { try { await eventDispatcher.Dispatch(eventEnvelope); } catch (Exception exception) { logger.LogError(exception, "Error during event processing of event {0}. {1}", eventEnvelope.Event.GetType().Name, exception.Message); } } }
private string SerializeEventEnvelope(EventEnvelope eventEnvelope) { var jsonSerializerSettings = jsonSerializerSettingsProvider.GetJsonSerializerSettings(); return(JsonConvert.SerializeObject(eventEnvelope, jsonSerializerSettings)); }