Esempio n. 1
0
        public WorkItem Pull(RequestMessage request)
        {
            if (request == null) throw new ArgumentNullException("request");

            request.Direction = MessageDirection.Incoming;

            Logger.Trace(String.Format("Incoming Request '{0}' for Event '{1}' has been queued."
                , request.CorrelationId
                , request.Event)
                /*, new XmlLogAttachment("Request", request)*/);

            Action sinkChainInvocation = () => Sinks.InvokeTransactional(request);
            WorkItem workItem = new WorkItem(request, sinkChainInvocation);

            workItem.Completed += delegate(object sender, EventArgs e)
            {
                Logger.Trace(String.Format("Incoming Request '{0}' for Event '{1}' was successfully processed."
                    , request.CorrelationId
                    , request.Event)
                    /*, new XmlLogAttachment("Request", request)*/);

                ReplyMessage reply = ReplyMessage.Success(request);
                //DistributedMessaging.Instance.Dispatchers.Outgoing.Push(reply);
            };

            workItem.Error += delegate(object sender, ItemEventArgs<Exception> e)
            {
                Exception exception = e.Item;
                Logger.Error(String.Format("Error occurred while processing Incoming Request '{0}' for Event '{1}'."
                    , request.CorrelationId
                    , request.Event)
                    , exception
                    /*, new XmlLogAttachment("Request", request)*/);

                if (exception is IgnoreRequestException)
                { return; }

                ReplyMessage reply = ReplyMessage.Failure(request);
                //DistributedMessaging.Instance.Dispatchers.Outgoing.Push(reply);
            };

            Queue.QueueWorkItem(workItem);
            return workItem;
        }
Esempio n. 2
0
        public WorkItem Push(RequestMessage request)
        {
            if (request == null) throw new ArgumentNullException("request");

            request.Direction = MessageDirection.Outgoing;

            Logger.Trace(String.Format("Outgoing Request '{0}' for Event '{1}' has been queued."
                , request.CorrelationId
                , request.Event)
                /*, new XmlLogAttachment("Request", request)*/);

            Action sinkChainInvocation = () => Sinks.InvokeTransactional(request);
            WorkItem workItem = new WorkItem(request, sinkChainInvocation);

            workItem.Completed += delegate(object sender, EventArgs e)
            {
                Logger.Trace(String.Format("Outgoing Request '{0}' for Event '{1}' was successfully processed."
                    , request.CorrelationId
                    , request.Event)
                    /*, new XmlLogAttachment("Request", request)*/);

                Channels.Broadcast(request);
            };

            workItem.Error += delegate(object sender, ItemEventArgs<Exception> e)
            {
                Exception exception = e.Item;
                Logger.Error(String.Format("Error occurred while processing Outgoing Request '{0}' for Event '{1}'."
                    , request.CorrelationId
                    , request.Event)
                    , exception
                    /*, new XmlLogAttachment("Request", request)*/);
            };

            Queue.QueueWorkItem(workItem);
            return workItem;
        }