//////////////////////////////
        public void Process(MessageToSendOnQueue pMessageToSendOnQueue)
        {
            _oMessageToProcess = pMessageToSendOnQueue;

            pMessageToSendOnQueue.MessageData.TraceStage.DateProcessingStarted = DateTime.UtcNow;

            _oAutoResetEvent.Set();
        }
        //////////////////////////////
        //          METHODS         //
        //////////////////////////////
        private void DoWork()
        {
            while (_bDoWork)
            {
                _oAutoResetEvent.WaitOne();

                var oStopwatch = new Stopwatch();

                oStopwatch.Start();

                if (_oMessageToProcess != null)
                {
                    try
                    {
                        if (this.ValidateMessage())
                        {
                            if (this.SerializeMessage())
                            {
                                this.SendMessage();

                                oStopwatch.Stop();

                                _oMessageToProcess.ProcessingTime = oStopwatch.ElapsedMilliseconds;

                                _oMessageSentDelegate(_oMessageToProcess);
                            }
                        }
                    }
                    //catch (NetworkException exception)
                    //{
                    //    _oMessageNotSentDelegate(_oMessageToProcess,
                    //                             new MessageDataNotSentError(
                    //                                 MessageDataNotSentErrorType.DestinationNotAvailable, DateTime.Now,
                    //                                 exception));
                    //}
                    catch (Exception exception)
                    {
                        _oMessageNotSentDelegate(_oMessageToProcess,
                                                 new MessageDataNotSentError(
                                                     MessageDataNotSentErrorType.NotExpectedException, DateTime.Now,
                                                     exception));
                    }
                }

                _oMessageToProcess = default(MessageToSendOnQueue);
            }
        }
示例#3
0
 //////////////////////////////
 private void MessageWasSent(MessageToSendOnQueue pMessageToSendOnQueue)
 {
     pMessageToSendOnQueue.MessageData.MessageWasSent(pMessageToSendOnQueue.MessageID, pMessageToSendOnQueue.ProcessingTime);
 }
示例#4
0
        //////////////////////////////
        private void MessageWasNotSent(MessageToSendOnQueue pMessageToSendOnQueue, MessageDataNotSentError pMessageDataNotSentError)
        {
            //if message has failed more that te number of maximum tries, then message has failed

            var messageToSendOnQueueError = new MessageToSendOnQueueError(pMessageToSendOnQueue.MessageData, pMessageToSendOnQueue.MessageDataToSendSettings);

            messageToSendOnQueueError.MessageDataSentFailures.Add(pMessageDataNotSentError);

            _oMessagesQueueFailedMessages.Value.Enqueue(messageToSendOnQueueError);

            ////
        }