Esempio n. 1
0
        private void MessageReceivedEventHandler(object sender, AdapterReceiveEventArgs e)
        {
            ContextTraceListener contextListener = ((ContextTraceListener)MessageEngine.Instance.Tracing.Listeners["ContextTraceListener"]);

            if (contextListener != null)
            {
                contextListener.ResetContext();
            }
        }
Esempio n. 2
0
 private void MessageReceivedEventHandler(object sender, AdapterReceiveEventArgs e)
 {
     OnMessageReceived(e.Message, e.ReceiveEndPoint);
 }
Esempio n. 3
0
        private void MessageReceivedEventHandler(object sender, AdapterReceiveEventArgs e)
        {
            if (!_isRunning)
            {
                return;
            }

            MultiPartMessage msg = e.Message;

            try
            {
                //Block incoming messages if startup in progress
                _blockThreadsWaitEvent.WaitOne();

                //Create message metadata
                msg.Metadata.Write("ReceiveUri", e.ReceiveEndPoint.Uri);
                msg.Metadata.Write("ReceiveAdapterId", e.ReceiveEndPoint.Adapter.AdapterId);

                ComponentPipeline             pipeline         = _receivePipelineDictionary[e.ReceiveEndPoint.Adapter];
                Collection <MultiPartMessage> resultCollection = pipeline.Execute(msg);

                if (resultCollection != null)
                {
                    List <CorrelationContext> contextCollection = new List <CorrelationContext>();

                    foreach (MultiPartMessage resultMsg in resultCollection)
                    {
                        CorrelationContext context = CorrelateMessage(resultMsg);

                        if (context == null)
                        {
                            SubscriptionManager.DistributeMessage(resultMsg);
                        }
                        else
                        {
                            contextCollection.Add(context);
                        }
                    }

                    foreach (CorrelationContext context in contextCollection)
                    {
                        //Signal the requestor thread that a response has been received
                        context.CompleteRequest();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ExceptionHelper.IsCritical(ex))
                {
                    throw;
                }
                else if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Error) == SourceLevels.Error && _isRunning)
                {
                    if (msg != null)
                    {
                        MessageEngine.Instance.Tracing.TraceData(TraceEventType.Error, msg.GetHashCode(), ex);
                    }
                    else
                    {
                        MessageEngine.Instance.Tracing.TraceData(TraceEventType.Error, 0, ex);
                    }
                }
            }
        }