Пример #1
0
        protected void ResolveAttributes(Type type, Type modelType)
        {
            if (!SendAck)
            {
                AutoAckAttribute ackAttribute = type.GetCustomAttribute <AutoAckAttribute>();
                SendAck = ackAttribute != null;
            }

            if (!SendNack)
            {
                AutoNackAttribute nackAttribute = type.GetCustomAttribute <AutoNackAttribute>();
                SendNack   = nackAttribute != null;
                NackReason = nackAttribute != null ? nackAttribute.Reason : NackReason.None;
            }

            RetryAttribute retryAttr = type.GetCustomAttribute <RetryAttribute>();

            if (retryAttr != null)
            {
                Retry = retryAttr;
            }

            if (PushExceptions == null)
            {
                PushExceptions = new List <TransportExceptionDescriptor>();
            }

            IEnumerable <PushExceptionsAttribute> pushAttributes = type.GetCustomAttributes <PushExceptionsAttribute>(true);

            foreach (PushExceptionsAttribute attribute in pushAttributes)
            {
                if (attribute.ExceptionType == null)
                {
                    DefaultPushException = new TransportExceptionDescriptor(attribute.ModelType);
                }
                else
                {
                    PushExceptions.Add(new TransportExceptionDescriptor(attribute.ModelType, attribute.ExceptionType));
                }
            }

            if (PublishExceptions == null)
            {
                PublishExceptions = new List <TransportExceptionDescriptor>();
            }

            IEnumerable <PublishExceptionsAttribute> publishAttributes = type.GetCustomAttributes <PublishExceptionsAttribute>(true);

            foreach (PublishExceptionsAttribute attribute in publishAttributes)
            {
                if (attribute.ExceptionType == null)
                {
                    DefaultPublishException = new TransportExceptionDescriptor(attribute.ModelType);
                }
                else
                {
                    PublishExceptions.Add(new TransportExceptionDescriptor(attribute.ModelType, attribute.ExceptionType));
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Push exceptions in specified types in consumers' consume operations to specified queue
 /// </summary>
 public ModelTypeConfigurator PushConsumerExceptions <TModel>(Type exceptionType)
     where TModel : ITransportableException, new()
 {
     PushExceptions.Add(new TransportExceptionDescriptor(typeof(TModel), exceptionType));
     return(this);
 }