コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        private string SerializeEventEnvelope(EventEnvelope eventEnvelope)
        {
            var jsonSerializerSettings = jsonSerializerSettingsProvider.GetJsonSerializerSettings();

            return(JsonConvert.SerializeObject(eventEnvelope, jsonSerializerSettings));
        }