/// <summary>
        /// Translates broker queue exception to fault message
        /// </summary>
        /// <param name="e">indicating the broker queue exception</param>
        /// <param name="relatesTo">indicating the relatesTo id</param>
        /// <param name="version">message version</param>
        /// <returns>fault message</returns>
        public static Message TranslateBrokerQueueExceptionToFaultMessage(BrokerQueueException e, Message request)
        {
            MessageVersion version = request.Headers.MessageVersion;
            FaultException <SessionFault> faultException = ExceptionHelper.ConvertBrokerQueueExceptionToFaultException(e);

            return(GenerateFaultMessage(request, version, faultException));
        }
Beispiel #2
0
        /// <summary>
        /// convert the exception to the fault exception that can be send back to the client.
        /// </summary>
        /// <param name="e">the exception.</param>
        /// <returns>the converted fault exception.</returns>
        public static FaultException <SessionFault> ConvertExceptionToFaultException(Exception e)
        {
            if (e == null)
            {
                return(null);
            }

            FaultException <SessionFault> faultException = e as FaultException <SessionFault>;

            if (faultException != null)
            {
                return(new FaultException <SessionFault>(faultException.Detail, faultException.Reason));
            }

            BrokerQueueException brokerQueueException = e as BrokerQueueException;

            if (brokerQueueException != null)
            {
                return(ExceptionHelper.ConvertBrokerQueueExceptionToFaultException(brokerQueueException));
            }

            if (e is TimeoutException)
            {
                ThrowHelper.ThrowSessionFault(SOAFaultCode.OperationTimeout, FetchExceptionDetails(e));
            }

            ThrowHelper.ThrowSessionFault(SOAFaultCode.UnknownError, SR.UnknownError, FetchExceptionDetails(e));

            Debug.Fail("Should not reach this line.");
            return(null);
        }
        /// <summary>
        /// convert the message queue native exception to the broker queue exception.
        /// </summary>
        /// <param name="e">the message queue native exception.</param>
        /// <returns>the broker queue exception.</returns>
        public static BrokerQueueException ConvertMessageQueueException(MessageQueueNativeException e)
        {
            BrokerQueueException exception = null;

            if (e != null)
            {
                BrokerQueueErrorCode errorCode = MapToBrokerQueueErrorCode((MessageQueueErrorCode)e.ErrorCode);
                exception = new BrokerQueueException((int)errorCode, e.ErrorMessage);
            }
            return(exception);
        }
        /// <summary>
        /// convert the message queue exception to the broker queue exception.
        /// </summary>
        /// <param name="e">the message queue exception.</param>
        /// <returns>the broker queue exception.</returns>
        public static BrokerQueueException ConvertMessageQueueException(MessageQueueException e)
        {
            BrokerQueueException exception = null;

            if (e != null)
            {
                BrokerQueueErrorCode errorCode = MapToBrokerQueueErrorCode(e.MessageQueueErrorCode);
                exception = new BrokerQueueException((int)errorCode, e.ToString());
            }
            return(exception);
        }
Beispiel #5
0
        /// <summary>
        /// Handle fatal broker queue exception
        /// </summary>
        /// <param name="sender">indicating the sender</param>
        /// <param name="fatalExceptionEventArgs">indicating the exception</param>
        private void Queue_OnFatalExceptionEvent(object sender, ExceptionEventArgs fatalExceptionEventArgs)
        {
            BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Critical, 0, "Fatal exception encountered. Exception = {0}", fatalExceptionEventArgs.Exception);
            BrokerQueueException bqException = fatalExceptionEventArgs.Exception as BrokerQueueException;

            if (bqException != null && bqException.ErrorCode == (int)BrokerQueueErrorCode.E_BQ_PERSIST_STORAGE_INSUFFICIENT)
            {
                this.monitor.FailServiceJob("Insufficient broker queue storage").GetAwaiter().GetResult();
            }
            else
            {
                BrokerTracing.TraceError("Unknown exception: {0}", fatalExceptionEventArgs);
            }
        }
Beispiel #6
0
        /// <summary>
        /// convert the broker queue exceptioni to the fault exception.
        /// </summary>
        /// <param name="e">the broker queue exception.</param>
        /// <returns>the converted fault exception.</returns>
        public static FaultException <SessionFault> ConvertBrokerQueueExceptionToFaultException(BrokerQueueException e)
        {
            FaultException <SessionFault> faultException = null;

            if (e != null)
            {
                string       reason          = null;
                SessionFault fault           = null;
                string       exceptionDetail = FetchExceptionDetails(e);

                switch ((BrokerQueueErrorCode)e.ErrorCode)
                {
                case BrokerQueueErrorCode.E_BQ_PERSIST_STORAGE_NOTAVAILABLE:
                    fault  = new SessionFault(SOAFaultCode.StorageServiceNotAvailble, SR.StorageServiceNotAvailble);
                    reason = SR.StorageServiceNotAvailble;
                    break;

                case BrokerQueueErrorCode.E_BQ_PERSIST_STORAGE_INSUFFICIENT:
                    fault  = new SessionFault(SOAFaultCode.StorageSpaceNotSufficient, SR.StorageSpaceNotSufficient);
                    reason = SR.StorageSpaceNotSufficient;
                    break;

                case BrokerQueueErrorCode.E_BQ_PERSIST_STORAGE_FAIL:
                    fault  = new SessionFault(SOAFaultCode.StorageFailure, SR.StorageFailure, exceptionDetail);
                    reason = String.Format(CultureInfo.CurrentCulture, SR.StorageFailure, exceptionDetail);
                    break;

                case BrokerQueueErrorCode.E_BQ_STATUS_CLOSED:
                    fault  = new SessionFault(SOAFaultCode.StorageClosed, SR.StorageClosed);
                    reason = SR.StorageClosed;
                    break;

                default:
                    fault  = new SessionFault(SOAFaultCode.UnknownError, SR.UnknownError, exceptionDetail);
                    reason = String.Format(CultureInfo.CurrentCulture, SR.UnknownError, exceptionDetail);
                    break;
                }

                faultException = new FaultException <SessionFault>(fault, reason);
            }

            return(faultException);
        }