Пример #1
0
 public Task Notify(Subscription subscriber, Event @event)
 {
     return(Task.Factory.StartNew(() =>
     {
         Console.WriteLine($"MessageId: {@event.Message.Header.MessageId} Event: {@event.Message.Header.MessageType} Subscriber: {subscriber.Type}:{subscriber.Endpoint}");
         telemetryService.LogTelemetry(@event.Header.InstanceId, "business-event", @event.Message.Header.MessageType,
                                       new { MessageHeader = @event.Message.Header, EventHeader = @event.Header });
     }));
 }
        public string RecordErrorForSubscriber(Subscription subscriber, Event @event, Exception exception)
        {
            var errorMessage = ConstructErrorMessage(subscriber, @event.Message,
                                                     exception.InnerException?.Message ?? exception.Message);

            Console.WriteLine(errorMessage);

            var telemetryService = new TelemetryService();

            telemetryService.LogTelemetry("0", "business-event", "subscription-error", new {
                Subscriber    = subscriber,
                MessageHeader = @event.Message.Header,
                EventHeader   = @event.Header,
                Exception     = exception,
                Message       = errorMessage
            });

            return(errorMessage);
        }
        public string RecordErrorForSubscriber(Subscription subscriber, Event @event, InvokeResponse response)
        {
            var errorMessage = ConstructErrorMessage(subscriber, @event.Message,
                                                     $"{response.StatusCode + " " + response.FunctionError + " " + response.Payload }");

            Console.WriteLine(errorMessage);

            var telemetryService = new TelemetryService();

            telemetryService.LogTelemetry("0", "business-event", "subscription-error", new
            {
                Subscriber    = subscriber,
                MessageHeader = @event.Message.Header,
                EventHeader   = @event.Header,
                Response      = response,
                Message       = errorMessage
            });

            return(errorMessage);
        }
        public string RecordErrorForSubscriber(Subscription subscriber, Event @event, HttpResponseMessage response)
        {
            var errorMessage = ConstructErrorMessage(subscriber, @event.Message,
                                                     $"{response.StatusCode + " " + response.ReasonPhrase + " " + response.Content.ReadAsStringAsync().Result }");

            Console.WriteLine(errorMessage);

            var telemetryService = new TelemetryService();

            telemetryService.LogTelemetry("0", "business-event", "subscription-error", new
            {
                Subscriber    = subscriber,
                MessageHeader = @event.Message.Header,
                EventHeader   = @event.Header,
                Response      = response,
                Message       = errorMessage
            });

            return(errorMessage);
        }