Exemplo n.º 1
0
        public bool Announce(IMessage message, IMessageSettingsOut messageSettings)
        {
            _processor.Type = messageSettings.MessageSettings["produce.ontopic"];
            var valueToSend = JsonHelperSerialiser.ToJson(message, JsonHelperSerialiserSettings.CamelCaseSerialiseSettings);

            var deliveryReport = producer.ProduceAsync(messageSettings.MessageSettings["produce.ontopic"], null, valueToSend);

            var result = deliveryReport.ConfigureAwait(false).GetAwaiter().GetResult(); // synchronously waits for message to be produced.

            if (result.IsSuccess())
            {
                producer.Flush(TimeSpan.FromSeconds(10));

                var messageToLog = new AllsaintsMessageLogger.LogMessage()
                {
                    Id           = message.Id,
                    DateStampUtc = message.DateStampUtc,
                    IsTest       = message.IsTest,
                    Message      = message,
                };
                _messageLogger.LogMessage(EventTypes.Sent, _processor, messageToLog);
                return(true);
            }
            else
            {
                OnError(result.Error.ToString());
                return(false);
            }
        }
Exemplo n.º 2
0
        public void LogFlow(string appID, int processId, IMessage message, string eventType, EntityTypeEnum messageType)
        {
            var messageTypeTest = message.GetType();
            var objectAsString  = JsonHelperSerialiser.ToJson(message, JsonHelperSerialiserSettings.CamelCaseSerialiseSettings);

            GlobalDiagnosticsContext.Set("entityId", message.Id.ToString());
            GlobalDiagnosticsContext.Set("entityType", (int)messageType);
            GlobalDiagnosticsContext.Set("event", eventType);
            GlobalDiagnosticsContext.Set("processId", processId);
            GlobalDiagnosticsContext.Set("processorId", "ConsoleAPP " + appID);
            GlobalDiagnosticsContext.Set("message", objectAsString);
            GlobalDiagnosticsContext.Set("isTest", message.IsTest ? 1 : 0);
            logger.LogDebug($"Flow processing log");
        }
Exemplo n.º 3
0
        public void LogMessage(EventId eventId, IProcessor processor, ILogMessage message)
        {
            var messageType    = message.Message.GetType().ToString();
            var objectAsString = JsonHelperSerialiser.ToJson(message.Message, JsonHelperSerialiserSettings.CamelCaseSerialiseSettings);

            GlobalDiagnosticsContext.Set("entityId", message.Id.ToString());
            GlobalDiagnosticsContext.Set("entityType", messageType);
            GlobalDiagnosticsContext.Set("event", eventId);
            GlobalDiagnosticsContext.Set("processId", processor.Type);
            GlobalDiagnosticsContext.Set("processorId", processor.Id);
            GlobalDiagnosticsContext.Set("processor", String.Format("ConsoleAPP {0}  IP: {1}", processor.HostName, processor.IpAddress));
            GlobalDiagnosticsContext.Set("message", objectAsString);
            GlobalDiagnosticsContext.Set("isTest", message.IsTest ? 1 : 0);
            logger.LogDebug(eventId, $"Flow processing log");
        }