/// <summary> /// Called when the event was fired (processing completed). /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void FiredEvent(IEventTopicInfo eventTopic, IPublication publication, object sender, EventArgs e) { INamedItem namedItem = publication.Publisher as INamedItem; if (namedItem != null) { this.log.DebugFormat( CultureInfo.InvariantCulture, "Fired event '{0}'. Invoked by publisher '{1}' with name '{2}' with sender '{3}' and EventArgs '{4}'.", eventTopic.Uri, publication.Publisher, namedItem.EventBrokerItemName, sender, e); } else { this.log.DebugFormat( CultureInfo.InvariantCulture, "Fired event '{0}'. Invoked by publisher '{1}' with sender '{2}' and EventArgs '{3}'.", eventTopic.Uri, publication.Publisher, sender, e); } }
/// <summary> /// Initializes a new instance of the <see cref="MissingMappingContext"/> class. /// </summary> /// <param name="eventTopic">The source event topic.</param> /// <param name="destinationTopic">The destination topic URI.</param> /// <param name="publication">The publication which triggered the event.</param> /// <param name="sender">The sender of the event.</param> /// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <param name="exception">The exception which contains information why the mapping was not possible.</param> public MissingMappingContext(IEventTopicInfo eventTopic, string destinationTopic, IPublication publication, object sender, EventArgs eventArgs, Exception exception) { this.Exception = exception; this.EventArgs = eventArgs; this.Sender = sender; this.Publication = publication; this.DestinationTopic = destinationTopic; this.EventTopic = eventTopic; }
public override void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper) { if (this.RunningOnUserInterfaceThread()) { this.CallWithoutThreadSwitch(eventTopic, subscriber, delegateWrapper, sender, e); } else { this.CallWithThreadSwitch(eventTopic, subscriber, delegateWrapper, sender, e); } }
private void CallWithoutThreadSwitch(IEventTopicInfo eventTopic, object subscriber, IDelegateWrapper delegateWrapper, object sender, EventArgs e) { try { delegateWrapper.Invoke(subscriber, sender, e); } catch (TargetInvocationException exception) { this.HandleSubscriberMethodException(exception, eventTopic); } }
/// <summary> /// Called after the event was relayed from the publication to the subscribers. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="handler">The handler.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void RelayedEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, IHandler handler, object sender, EventArgs e) { Debug.WriteLine( "Relayed event '{6}' from publisher '{0}' [{1}] to subscriber '{2}' [{3}] with EventArgs '{4}' with handler '{5}'.", publication.Publisher, publication.Publisher is INamedItem ? ((INamedItem)publication.Publisher).EventBrokerItemName : string.Empty, subscription.Subscriber, subscription.Subscriber is INamedItem ? ((INamedItem)subscription.Subscriber).EventBrokerItemName : string.Empty, e, handler, eventTopic.Uri); }
public void IsCandidate_MustExecuteCandidateSelector() { bool wasCalled = false; IEventTopicInfo topicResult = null; var testee = CreateTestee(topic => { wasCalled = true; topicResult = topic; return(true); }, from => string.Empty); testee.IsCandidate(this.eventTopicInfo.Object); Assert.True(wasCalled, "CandidateSelector was not called!"); Assert.Same(this.eventTopicInfo.Object, topicResult); }
public EventBrokerLogExtensionTest() { this.testee = new EventBrokerLogExtension(); this.log4Net = new Log4netHelper(); this.eventTopicInfo = CreateEventTopicInfo(); this.publication = CreatePublication(); this.publicationWithNamedPublisher = CreatePublicationWithNamedPublisher(); this.sender = CreateSender(); this.eventArgs = CreateEventArgs(); }
private void EventTopicFireHandler(IEventTopicInfo eventTopic, object sender, EventArgs e, IPublication publication) { if (this.Subscriber == null) { return; } this.extensionHost.ForEach(extension => extension.RelayingEvent(eventTopic, publication, this, this.handler, sender, e)); this.handler.Handle(eventTopic, this.Subscriber, sender, e, this.delegateWrapper); this.extensionHost.ForEach(extension => extension.RelayedEvent(eventTopic, publication, this, this.handler, sender, e)); }
public override void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper) { Ensure.ArgumentNotNull(delegateWrapper, "delegateWrapper"); try { delegateWrapper.Invoke(subscriber, sender, e); } catch (TargetInvocationException ex) { this.HandleSubscriberMethodException(ex, eventTopic); } }
/// <summary> /// Called before an event is relayed from the publication to the subscribers. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="handler">The handler.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void RelayingEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, IHandler handler, object sender, EventArgs e) { this.log.DebugFormat( CultureInfo.InvariantCulture, "Relaying event '{6}' from publisher '{0}' [{1}] to subscriber '{2}' [{3}] with EventArgs '{4}' with handler '{5}'.", publication.Publisher, publication.Publisher is INamedItem ? ((INamedItem)publication.Publisher).EventBrokerItemName : string.Empty, subscription.Subscriber, subscription.Subscriber is INamedItem ? ((INamedItem)subscription.Subscriber).EventBrokerItemName : string.Empty, e, handler, eventTopic.Uri); }
public override void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper) { Guard.AgainstNullArgument(nameof(delegateWrapper), delegateWrapper); try { delegateWrapper.Invoke(subscriber, sender, e); } catch (TargetInvocationException ex) { this.HandleSubscriberMethodException(ex, eventTopic); } }
public void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper) { IEventScopeRegistry registry = this.scopeHolder.Current; if (registry != null) { registry.Register(() => this.handler.Handle(eventTopic, subscriber, sender, e, delegateWrapper)); } else { this.handler.Handle(eventTopic, subscriber, sender, e, delegateWrapper); } }
/// <summary> /// Called after an event topic was disposed. /// </summary> /// <param name="eventTopic">The event topic.</param> public override void Disposed(IEventTopicInfo eventTopic) { base.Disposed(eventTopic); if (!this.Topics.Contains(eventTopic)) { return; } lock (this.locker) { this.Topics.Remove(eventTopic); } }
/// <summary> /// Called after an event topic was disposed. /// </summary> /// <param name="eventTopic">The event topic.</param> public override void Disposed(IEventTopicInfo eventTopic) { base.Disposed(eventTopic); Ensure.ArgumentNotNull(eventTopic, "eventTopic"); lock (this.locker) { string uri = eventTopic.Uri; if (this.topics.Contains(uri)) { this.topics.Remove(uri); } } }
/// <summary> /// Called after an event topic was created. /// </summary> /// <param name="eventTopic">The event topic.</param> public override void CreatedTopic(IEventTopicInfo eventTopic) { base.CreatedTopic(eventTopic); this.AssertEventBrokerManaged(); if (!this.TopicConvention.IsCandidate(eventTopic)) { return; } lock (this.locker) { this.Topics.Add(eventTopic); } }
public override void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper) { this.syncContextHolder.SyncContext.Post( delegate(object data) { try { ((IDelegateWrapper)data).Invoke(subscriber, sender, e); } catch (TargetInvocationException exception) { this.HandleSubscriberMethodException(exception, eventTopic); } }, delegateWrapper); }
/// <summary> /// Handles a subscriber method exception by passing it to all extensions and re-throwing the inner exception in case that none of the /// extensions handled it. /// </summary> /// <param name="targetInvocationException">The targetInvocationException.</param> /// <param name="eventTopic">The event topic.</param> protected void HandleSubscriberMethodException(TargetInvocationException targetInvocationException, IEventTopicInfo eventTopic) { Ensure.ArgumentNotNull(targetInvocationException, "targetInvocationException"); var innerException = targetInvocationException.InnerException; innerException.PreserveStackTrace(); var context = new ExceptionHandlingContext(); this.ExtensionHost.ForEach(extension => extension.SubscriberExceptionOccurred(eventTopic, innerException, context)); if (!context.Handled) { throw innerException; } }
private void CallWithThreadSwitch(IEventTopicInfo eventTopic, object subscriber, IDelegateWrapper delegateWrapper, object sender, EventArgs e) { this.syncContextHolder.SyncContext.Send( delegate(object data) { try { ((IDelegateWrapper)data).Invoke(subscriber, sender, e); } catch (TargetInvocationException exception) { this.HandleSubscriberMethodException(exception, eventTopic); } }, delegateWrapper); }
public override void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper) { ThreadPool.QueueUserWorkItem( delegate(object state) { try { var args = (CallInBackgroundArguments)state; args.DelegateWrapper.Invoke(args.Subscriber, args.Sender, args.EventArgs); } catch (TargetInvocationException exception) { this.HandleSubscriberMethodException(exception, eventTopic); } }, new CallInBackgroundArguments(subscriber, sender, e, delegateWrapper)); }
/// <summary> /// Called after a subscription was added to an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="subscription">The subscription.</param> public override void AddedSubscription(IEventTopicInfo eventTopic, ISubscription subscription) { using (TextWriter writer = new StringWriter(CultureInfo.InvariantCulture)) { foreach (ISubscriptionMatcher subscriptionMatcher in subscription.SubscriptionMatchers) { subscriptionMatcher.DescribeTo(writer); writer.Write(", "); } Debug.WriteLine( "Added subscription '{0}.{1}' to topic '{2}' with matchers '{3}'.", subscription.Subscriber != null ? subscription.Subscriber.GetType().FullName : "-", subscription.HandlerMethodName, eventTopic.Uri, writer); } }
/// <summary> /// Called after a publication was added to an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> public override void AddedPublication(IEventTopicInfo eventTopic, IPublication publication) { using (TextWriter writer = new StringWriter(CultureInfo.InvariantCulture)) { foreach (IPublicationMatcher publicationMatcher in publication.PublicationMatchers) { publicationMatcher.DescribeTo(writer); writer.Write(", "); } Debug.WriteLine( "Added publication '{0}.{1}' to topic '{2}' with matchers '{3}'.", publication.Publisher != null ? publication.Publisher.GetType().FullName : "-", publication.EventName, eventTopic.Uri, writer); } }
/// <summary> /// Called after a subscription was added to an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="subscription">The subscription.</param> public override void AddedSubscription(IEventTopicInfo eventTopic, ISubscription subscription) { using (TextWriter writer = new StringWriter(CultureInfo.InvariantCulture)) { foreach (ISubscriptionMatcher subscriptionMatcher in subscription.SubscriptionMatchers) { subscriptionMatcher.DescribeTo(writer); writer.Write(", "); } Console.WriteLine( "Added subscription '{0}.{1}' to topic '{2}' with matchers '{3}'.", subscription.Subscriber != null ? subscription.Subscriber.GetType().FullName : "-", subscription.HandlerMethodName, eventTopic.Uri, writer); } }
/// <summary> /// Called after a publication was added to an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> public override void AddedPublication(IEventTopicInfo eventTopic, IPublication publication) { using (TextWriter writer = new StringWriter(CultureInfo.InvariantCulture)) { foreach (IPublicationMatcher publicationMatcher in publication.PublicationMatchers) { publicationMatcher.DescribeTo(writer); writer.Write(", "); } Console.WriteLine( "Added publication '{0}.{1}' to topic '{2}' with matchers '{3}'.", publication.Publisher != null ? publication.Publisher.GetType().FullName : "-", publication.EventName, eventTopic.Uri, writer); } }
/// <summary> /// Called when the event was fired (processing completed). /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void FiredEvent(IEventTopicInfo eventTopic, IPublication publication, object sender, EventArgs e) { INamedItem namedItem = publication.Publisher as INamedItem; if (namedItem != null) { Debug.WriteLine( "Fired event '{0}'. Invoked by publisher '{1}' with name '{2}' with sender '{3}' and EventArgs '{4}'.", eventTopic.Uri, publication.Publisher, namedItem.EventBrokerItemName, sender, e); } else { Debug.WriteLine( "Fired event '{0}'. Invoked by publisher '{1}' with sender '{2}' and EventArgs '{3}'.", eventTopic.Uri, publication.Publisher, sender, e); } }
/// <summary> /// Called when a publication or subscription matcher did not match and the event was not relayed to a subscription. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void SkippedEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, object sender, EventArgs e) { List <IMatcher> matchers = new List <IMatcher>(); var publicationMatchers = from matcher in publication.PublicationMatchers where !matcher.Match(publication, subscription, e) select matcher; var subscriptionMatchers = from matcher in subscription.SubscriptionMatchers where !matcher.Match(publication, subscription, e) select matcher; matchers.AddRange(publicationMatchers); matchers.AddRange(subscriptionMatchers); StringBuilder sb = new StringBuilder(); using (TextWriter writer = new StringWriter(sb, CultureInfo.InvariantCulture)) { foreach (IMatcher matcher in matchers) { matcher.DescribeTo(writer); writer.Write(", "); } } if (sb.Length > 0) { sb.Length -= 2; } this.log.DebugFormat( CultureInfo.InvariantCulture, "Skipped event '{0}' from publisher '{1}' [{2}] to subscriber '{3}' [{4}] with EventArgs '{5}' because the matchers '{6}' did not match.", eventTopic.Uri, publication.Publisher, publication.Publisher is INamedItem ? ((INamedItem)publication.Publisher).EventBrokerItemName : string.Empty, subscription.Subscriber, subscription.Subscriber is INamedItem ? ((INamedItem)subscription.Subscriber).EventBrokerItemName : string.Empty, e, sb); }
public override void SubscriberExceptionOccurred(IEventTopicInfo eventTopic, Exception exception, ExceptionHandlingContext context) { context.SetHandled(); }
/// <summary> /// Determines whether the specified event topic is a candidate to process. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <returns> /// <c>true</c> if the specified event topic is candidate; otherwise, <c>false</c>. /// </returns> public bool IsCandidate(IEventTopicInfo eventTopic) { return StartsWith(eventTopic, EventTopicUriInput); }
/// <summary> /// Called when an exception occurred during event handling by a subscriber. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="exception">The exception.</param> /// <param name="context">The context providing information whether the exception is handled by an extension or is re-thrown.</param> public override void SubscriberExceptionOccurred(IEventTopicInfo eventTopic, Exception exception, ExceptionHandlingContext context) { this.log.Error( string.Format("An exception was thrown during handling the topic '{0}'", eventTopic.Uri), exception); }
/// <summary> /// Called after the event was relayed from the publication to the subscribers. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="handler">The handler.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void RelayedEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, IHandler handler, object sender, EventArgs e) { this.log.DebugFormat( "Relayed event '{6}' from publisher '{0}' [{1}] to subscriber '{2}' [{3}] with EventArgs '{4}' with handler '{5}'.", publication.Publisher, publication.Publisher is INamedItem ? ((INamedItem)publication.Publisher).EventBrokerItemName : string.Empty, subscription.Subscriber, subscription.Subscriber is INamedItem ? ((INamedItem)subscription.Subscriber).EventBrokerItemName : string.Empty, e, handler, eventTopic.Uri); }
/// <summary> /// Called after a publication was removed from an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> public override void RemovedPublication(IEventTopicInfo eventTopic, IPublication publication) { this.log.DebugFormat( "Removed publication '{0}.{1}' from topic '{2}'.", publication.Publisher != null ? publication.Publisher.GetType().FullName : "-", publication.EventName, eventTopic.Uri); }
/// <summary> /// Called when an event is fired. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void FiringEvent(IEventTopicInfo eventTopic, IPublication publication, object sender, EventArgs e) { this.log.DebugFormat( "Firing event '{0}'. Invoked by publisher '{1}' with EventArgs '{2}'.", eventTopic.Uri, sender, e); }
/// <summary> /// Called after a publication was created. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> public override void CreatedPublication(IEventTopicInfo eventTopic, IPublication publication) { }
/// <summary> /// Called after a publication was removed from an event topic. /// </summary> /// <param name="eventTopic">The event topic. Null if removed by code.</param> /// <param name="publication">The publication.</param> public virtual void RemovedPublication(IEventTopicInfo eventTopic, IPublication publication) { }
public abstract void Handle(IEventTopicInfo eventTopic, object subscriber, object sender, EventArgs e, IDelegateWrapper delegateWrapper);
public override void FiringEvent(IEventTopicInfo eventTopic, IPublication publication, object sender, EventArgs e) { base.FiringEvent(eventTopic, publication, sender, e); this.interceptedPublication = publication; }
/// <summary> /// Called after an event topic was created. /// </summary> /// <param name="eventTopic">The event topic.</param> public override void CreatedTopic(IEventTopicInfo eventTopic) { base.CreatedTopic(eventTopic); Ensure.ArgumentNotNull(eventTopic, "eventTopic"); if (!this.SelectionStrategy.SelectTopic(eventTopic)) { return; } var publicationsWithNotAllowedRestrictions = eventTopic.Publications.Where(p => p.HandlerRestriction != HandlerRestriction.Asynchronous).ToList(); if (publicationsWithNotAllowedRestrictions.Any()) { string message = BuildPublicationsWithNotAllowedHandlerRestrictionsMessage(publicationsWithNotAllowedRestrictions); throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Only asynchronous handling of events is allowed! The wrong publications are: {0}", message)); } lock (this.locker) { this.topics.Add(eventTopic.Uri); } }
/// <summary> /// Called after a subscription was created. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="subscription">The subscription.</param> public virtual void CreatedSubscription(IEventTopicInfo eventTopic, ISubscription subscription) { }
/// <summary> /// Called after an event topic was disposed. /// </summary> /// <param name="eventTopic">The event topic.</param> public virtual void Disposed(IEventTopicInfo eventTopic) { }
/// <summary> /// Called after an event topic was created. /// </summary> /// <param name="eventTopic">The event topic.</param> public override void CreatedTopic(IEventTopicInfo eventTopic) { this.log.DebugFormat("Topic created: '{0}'.", eventTopic.Uri); }
/// <summary> /// Called when an exception occurred during event handling by a subscriber. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="exception">The exception.</param> /// <param name="context">The context providing information whether the exception is handled by an extension or is re-thrown.</param> public virtual void SubscriberExceptionOccurred(IEventTopicInfo eventTopic, Exception exception, ExceptionHandlingContext context) { }
/// <summary> /// Called after a subscription was created. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="subscription">The subscription.</param> public override void CreatedSubscription(IEventTopicInfo eventTopic, ISubscription subscription) { }
/// <summary> /// Called after the event was relayed from the publication to the subscribers. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="handler">The handler.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public virtual void RelayedEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, IHandler handler, object sender, EventArgs e) { }
/// <summary> /// Called after a publication was added to an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> public override void AddedPublication(IEventTopicInfo eventTopic, IPublication publication) { using (TextWriter writer = new StringWriter()) { foreach (IPublicationMatcher publicationMatcher in publication.PublicationMatchers) { publicationMatcher.DescribeTo(writer); writer.Write(", "); } this.log.DebugFormat( "Added publication '{0}.{1}' to topic '{2}' with matchers '{3}'.", publication.Publisher != null ? publication.Publisher.GetType().FullName : "-", publication.EventName, eventTopic.Uri, writer); } }
/// <summary> /// Called when a publication or subscription matcher did not match and the event was not relayed to a subscription. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public virtual void SkippedEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, object sender, EventArgs e) { }
/// <summary> /// Called after a subscription was removed from an event topic. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="subscription">The subscription.</param> public override void RemovedSubscription(IEventTopicInfo eventTopic, ISubscription subscription) { this.log.DebugFormat( "Removed subscription '{0}.{1}' from topic '{2}'.", subscription.Subscriber != null ? subscription.Subscriber.GetType().FullName : "-", subscription.HandlerMethodName, eventTopic.Uri); }
/// <summary> /// Called when the event was fired (processing completed). /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public virtual void FiredEvent(IEventTopicInfo eventTopic, IPublication publication, object sender, EventArgs e) { }
/// <summary> /// Called when a publication or subscription matcher did not match and the event was not relayed to a subscription. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="subscription">The subscription.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void SkippedEvent(IEventTopicInfo eventTopic, IPublication publication, ISubscription subscription, object sender, EventArgs e) { List<IMatcher> matchers = new List<IMatcher>(); var publicationMatchers = from matcher in publication.PublicationMatchers where !matcher.Match(publication, subscription, e) select matcher; var subscriptionMatchers = from matcher in subscription.SubscriptionMatchers where !matcher.Match(publication, subscription, e) select matcher; matchers.AddRange(publicationMatchers); matchers.AddRange(subscriptionMatchers); StringBuilder sb = new StringBuilder(); using (TextWriter writer = new StringWriter(sb)) { foreach (IMatcher matcher in matchers) { matcher.DescribeTo(writer); writer.Write(", "); } } if (sb.Length > 0) { sb.Length -= 2; } this.log.DebugFormat( "Skipped event '{0}' from publisher '{1}' [{2}] to subscriber '{3}' [{4}] with EventArgs '{5}' because the matchers '{6}' did not match.", eventTopic.Uri, publication.Publisher, publication.Publisher is INamedItem ? ((INamedItem)publication.Publisher).EventBrokerItemName : string.Empty, subscription.Subscriber, subscription.Subscriber is INamedItem ? ((INamedItem)subscription.Subscriber).EventBrokerItemName : string.Empty, e, sb); }
/// <summary> /// Called after an event topic was created. /// </summary> /// <param name="eventTopic">The event topic.</param> public virtual void CreatedTopic(IEventTopicInfo eventTopic) { }
/// <summary> /// Determines whether the topics URI starts with start. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="start">The start of the topic.</param> /// <returns><see langword="true"/> if the topic URI starts with start; /// otherwise <see langword="false"/>.</returns> private static bool StartsWith(IEventTopicInfo eventTopic, string start) { return eventTopic.Uri.StartsWith(start, StringComparison.Ordinal); }
/// <summary> /// Called after a publication was created. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> public virtual void CreatedPublication(IEventTopicInfo eventTopic, IPublication publication) { }
/// <summary> /// Determines whether the specified event topic is a candidate to process. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <returns> /// <c>true</c> if the specified event topic is candidate; otherwise, <c>false</c>. /// </returns> public bool IsCandidate(IEventTopicInfo eventTopic) { return(StartsWith(eventTopic, EventTopicUriInput)); }
/// <summary> /// Determines whether the specified event topic is a candidate to process. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <returns> /// <c>true</c> if the specified event topic is candidate; otherwise, <c>false</c>. /// </returns> /// <remarks>The mapped side must also be included!</remarks> public bool IsCandidate(IEventTopicInfo eventTopic) { return this.candidateSelector(eventTopic); }