Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Dev) Exception logging for EventProcessorHost background exceptions … #1714

Closed
wants to merge 1 commit into from

Conversation

mathewc
Copy link
Member

@mathewc mathewc commented May 22, 2018

…(#1705)

This PR is the dev branch counterpart to #1712

/// <summary>
/// Constructs a new instance.
/// </summary>
/// <param name="options">The optional <see cref="EventProcessorOptions"/> to use when receiving events.</param>
public EventHubConfiguration(EventProcessorOptions options)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the options a get/set property, symmetric with ServiceBusConfiguration.MessageOptions. All our other config classes have default constructors with settable properties.

@@ -437,6 +439,13 @@ private static Task<object> ConvertPocoToEventData(object arg, Attribute attrRes
return Task.FromResult<object>(ConvertString2EventData(JsonConvert.SerializeObject(arg)));
}

internal Action<ExceptionReceivedEventArgs> ExceptionHandler { get; set; }

private void ExceptionReceivedHandler(ExceptionReceivedEventArgs args)
Copy link
Member Author

@mathewc mathewc May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This somewhat strange level of indirection is necessary because the options class is constructed (and handler wired up) before initialize runs and can configure the actual handler. This handler is a ctor param of EventProcessorOptions so must be set up early.

Note that in the v1 version of the EH library the handler is an event so we don't have to do this - we just add an event handler during initialization.

@mathewc mathewc requested a review from paulbatum May 22, 2018 22:06
// ensure the EventProcessorOptions ExceptionReceived event is wired up
var eventProcessorOptions = eventHubConfiguration.EventProcessorOptions;
var ex = new EventHubsException(false, "Kaboom!");
var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They've decided to make their event args ctor internal so you can't mock it at all :(

@mathewc mathewc force-pushed the mathewc-work-dev branch from 1585b1a to f96699b Compare May 23, 2018 20:27
@mathewc mathewc closed this May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant