コード例 #1
0
 private void AssertValid(IMessageSubscriber _Instance, Type _Origin)
 {
     if (_Instance != null && (_Instance.GetType() != _Origin && !_Instance.GetType().IsSubclassOf(_Origin)))
     {
         throw new ArgumentException("Sending instance expected to be of type " + _Origin.Name);
     }
 }
コード例 #2
0
 internal SubscriberInfo(IMessageSubscriber Subscriber)
 {
     SubscriberType = Subscriber.GetType();
     Instance = Subscriber;
     Roles = new RoleSet(SubscriberType);
     _ObservedSet = new UniqueSet<IMessageSubscriber>();
 }
コード例 #3
0
 internal SubscriberInfo(IMessageSubscriber Subscriber)
 {
     SubscriberType = Subscriber.GetType();
     Instance       = Subscriber;
     Roles          = new RoleSet(SubscriberType);
     _ObservedSet   = new UniqueSet <IMessageSubscriber>();
 }
コード例 #4
0
        /// <summary>
        /// Sends to subscriber.
        /// </summary>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="envelope">The envelope.</param>
        /// <param name="session">The session.</param>
        protected void SendToSubscriber(IMessageSubscriber subscriber, IMessageEnvelope envelope, ISessionContext session)
        {
            bool retry      = true;
            int  retryCount = 0;

            while (retry)
            {
                retryCount++;
                try
                {
                    InvokeOnMessage(subscriber, envelope, retryCount, session);
                    retry = false;
                    logger.LogSubscribeSuccess(envelope, string.Format(CultureInfo.CurrentCulture, "Subscriber {0} successfully processed message {1} (UID: {2}",
                                                                       subscriber.GetType().FullName, envelope.Message.GetType().FullName, envelope.MessageUID), subscriber.GetType());
                }
                catch (Exception.MessagingException messagingEx)
                {
                    logger.LogSubscribeFailure(envelope, messagingEx.Message, messagingEx, subscriber.GetType());
                    retry = messagingEx.Retry;
                    if (retry)
                    {
                        TimeSpan sleepTime = TimeSpan.FromMinutes(MaxWaitInMinutes);

                        if (messagingEx.RetryInterval.Minutes < sleepTime.Minutes)
                        {
                            sleepTime = messagingEx.RetryInterval;
                        }

                        Thread.Sleep(sleepTime.Milliseconds);
                    }
                }
                catch (System.Exception exception)
                {
                    logger.LogSubscribeFailure(envelope, exception.Message, exception, subscriber.GetType());
                    retry = false;
                }
                if (retryCount >= MaxRetries)
                {
                    retry = false;
                }
            }
        }
コード例 #5
0
ファイル: Message.cs プロジェクト: lokeldigital/CoolFramework
 public Message(IMessageSubscriber _OriginInstance, Type _TargetRole, object _EventType, object _Payload)
     : this(_OriginInstance.GetType(), _TargetRole, _EventType, _OriginInstance, _Payload)
 {
 }
コード例 #6
0
ファイル: Message.cs プロジェクト: lokeldigital/CoolFramework
 private void AssertValid(IMessageSubscriber _Instance, Type _Origin)
 {
     if ( _Instance != null && (_Instance.GetType() != _Origin && ! _Instance.GetType().IsSubclassOf(_Origin) )) {
         throw new ArgumentException("Sending instance expected to be of type " + _Origin.Name);
     }
 }
コード例 #7
0
 public Message(IMessageSubscriber _OriginInstance, Type _TargetRole, object _EventType, object _Payload)
     : this(_OriginInstance.GetType(), _TargetRole, _EventType, _OriginInstance, _Payload)
 {
 }