Esempio n. 1
0
            private async Task ProcessingTaskAsync(MemoryQueue.Message message)
            {
                if (message == null)
                {
                    return;
                }
                try
                {
                    Core.Log.LibVerbose("Received message from the memory queue '{0}/{1}'", Connection.Route, Connection.Name);
                    var messageBody = message.Value;
                    switch (messageBody)
                    {
                    case RequestMessage request when request.Header != null:
                        if (_cloneObject)
                        {
                            request.Body = request.Body.DeepClone();
                        }
                        request.Header.ApplicationReceivedTime = Core.Now;
                        Counters.IncrementReceivingTime(request.Header.TotalTime);
                        if (request.Header.ClientName != Config.Name)
                        {
                            Core.Log.Warning("The Message Client Name '{0}' is different from the Server Name '{1}'", request.Header.ClientName, Config.Name);
                        }
                        var evArgs = new RequestReceivedEventArgs(_name, Connection, request, 1);
                        if (request.Header.ResponseQueue != null)
                        {
                            evArgs.ResponseQueues.Add(request.Header.ResponseQueue);
                        }
                        await OnRequestReceivedAsync(evArgs).ConfigureAwait(false);

                        break;

                    case ResponseMessage response when response.Header != null:
                        if (_cloneObject)
                        {
                            response.Body = response.Body.DeepClone();
                        }
                        response.Header.Response.ApplicationReceivedTime = Core.Now;
                        Counters.IncrementReceivingTime(response.Header.Response.TotalTime);
                        await OnResponseReceivedAsync(new ResponseReceivedEventArgs(_name, response, 1)).ConfigureAwait(false);

                        break;
                    }

                    Counters.IncrementTotalMessagesProccesed();
                }
                catch (Exception ex)
                {
                    Counters.IncrementTotalExceptions();
                    Core.Log.Write(ex);
                }
            }
Esempio n. 2
0
            private async Task ProcessingTaskAsync(MemoryQueue.Message message)
            {
                if (message is null)
                {
                    return;
                }
                try
                {
                    var messageBody = message.Value;
                    switch (messageBody)
                    {
                    case RequestMessage request when request.Header != null:
                        request.Header.ApplicationReceivedTime = Core.Now;
                        Counters.IncrementReceivingTime(request.Header.TotalTime);
                        if (request.Header.ClientName != Config.Name)
                        {
                            Core.Log.Warning("The Message Client Name '{0}' is different from the Server Name '{1}'", request.Header.ClientName, Config.Name);
                        }
                        var evArgs = new RequestReceivedEventArgs(_name, Connection, request, 1, SenderSerializer, Config.RequestOptions.ServerReceiverOptions.CancellationBeforeClientResponseTimeoutInSec);
                        if (request.Header.ResponseQueue != null)
                        {
                            evArgs.ResponseQueues.Add(request.Header.ResponseQueue);
                        }
                        await OnRequestReceivedAsync(evArgs).ConfigureAwait(false);

                        break;

                    case ResponseMessage response when response.Header != null:
                        response.Header.Response.ApplicationReceivedTime = Core.Now;
                        Counters.IncrementReceivingTime(response.Header.Response.TotalTime);
                        await OnResponseReceivedAsync(new ResponseReceivedEventArgs(_name, response, 1)).ConfigureAwait(false);

                        break;
                    }

                    Counters.IncrementTotalMessagesProccesed();
                }
                catch (Exception ex)
                {
                    Counters.IncrementTotalExceptions();
                    Core.Log.Write(ex);
                }
            }