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); } }
internal SubscriberInfo(IMessageSubscriber Subscriber) { SubscriberType = Subscriber.GetType(); Instance = Subscriber; Roles = new RoleSet(SubscriberType); _ObservedSet = new UniqueSet<IMessageSubscriber>(); }
internal SubscriberInfo(IMessageSubscriber Subscriber) { SubscriberType = Subscriber.GetType(); Instance = Subscriber; Roles = new RoleSet(SubscriberType); _ObservedSet = new UniqueSet <IMessageSubscriber>(); }
/// <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; } } }
public Message(IMessageSubscriber _OriginInstance, Type _TargetRole, object _EventType, object _Payload) : this(_OriginInstance.GetType(), _TargetRole, _EventType, _OriginInstance, _Payload) { }
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); } }