void IKafkaMessageHandler.Handle(KafkaMessage message, IKafkaMessageContext context)
        {
            var eNodeMessage           = _jsonSerializer.Deserialize <ENodeMessage>(message.Value);
            var applicationMessageType = _typeNameProvider.GetType(eNodeMessage.Tag);
            var applicationMessage     = _jsonSerializer.Deserialize(eNodeMessage.Body, applicationMessageType) as IApplicationMessage;
            var processContext         = new KafkaMessageProcessContext(message, context);
            var processingMessage      = new ProcessingApplicationMessage(applicationMessage, processContext);

            _logger.InfoFormat("ENode application message received, messageId: {0}, routingKey: {1}", applicationMessage.Id, applicationMessage.GetRoutingKey());
            _processor.Process(processingMessage);
        }
Ejemplo n.º 2
0
        public void Handle(KafkaMessage message, IKafkaMessageContext context)
        {
            var eNodeMessage     = _jsonSerializer.Deserialize <ENodeMessage>(message.Value);
            var exceptionMessage = _jsonSerializer.Deserialize <PublishableExceptionMessage>(eNodeMessage.Body);
            var exceptionType    = _typeNameProvider.GetType(eNodeMessage.Tag);
            var exception        = FormatterServices.GetUninitializedObject(exceptionType) as IPublishableException;

            exception.Id        = exceptionMessage.UniqueId;
            exception.Timestamp = exceptionMessage.Timestamp;
            exception.RestoreFrom(exceptionMessage.SerializableInfo);
            var sequenceMessage = exception as ISequenceMessage;

            if (sequenceMessage != null)
            {
                sequenceMessage.AggregateRootTypeName = exceptionMessage.AggregateRootTypeName;
                sequenceMessage.AggregateRootStringId = exceptionMessage.AggregateRootId;
            }
            var processContext    = new KafkaMessageProcessContext(message, context);
            var processingMessage = new ProcessingPublishableExceptionMessage(exception, processContext);

            _logger.InfoFormat("ENode exception message received, messageId: {0}, aggregateRootId: {1}, aggregateRootType: {2}", exceptionMessage.UniqueId, exceptionMessage.AggregateRootId, exceptionMessage.AggregateRootTypeName);
            _publishableExceptionProcessor.Process(processingMessage);
        }