Skip to content

Eventing

Michael Vivet edited this page Jan 30, 2018 · 49 revisions

Nano supports different ways of publishing and subscribing to events.

Adding eventing annotations to model implementations, provides a way of synchronizing entities between applications. Additionally, custom event models can be implemented and published and well as consumed.

Table of Contents


Summary

Nano registers the interfaces ILogger and ILogger<T> during application startup.

The ILoggingProvider is registered during startup, and the implementing type defines the logging provider used in the application.


Configuration

The Eventing section of the configuration defines the behavior of eventing (message queuing) in the application.

The section is serialized into an instance of EventingOptions, and injected as dependency during startup, thus available for injection throughout the application.

See Appendix - App Settings - Eventing for details about the section and the meaning of the variables.

Eventing Section
"Eventing": {
  "Host": null,
  "VHost": null,
  "Port": 5672,
  "AuthenticationCredential": {
    "Username": null,
    "Password": null
  },
  "UseSsl": false,
  "Timeout": 30,
  "Heartbeat": 0
}

Eventing Provider

Nano provides several eventing providers (and more added on request), so usually there is no need to implement a custom data provider for your application.

Eventing providers implements the interface IEventingProvider. It contains a single method Configure(...), that is responsible for handling any configuration and setup required for the eventing provider.

The eventing providers currently supported by Nano, can be referenced in the Appendix - Supported Providers.


Dependency Injection

The eventing provider must be registered as dependencies. Invoke the method .AddEventing<TProvider>();, using the eventing provider implementation as generic type parameters.

Sample Implementation
.ConfigureServices(x =>
{
    x.AddEventing<EasyNetQProvider>();
})
Injected Dependencies
  • Nano.Eventing.EventingOptions
  • Nano.Eventing.Interfaces.IEventing
  • Nano.Eventing.Interfaces.IEventingProvider
  • Nano.Eventing.Interfaces.IEventingHandler<>

For a full list of supported dependencies, see Appendix: Injected Dependencies.


Null Eventing

By default, IEventing resolves to NullEventing, which as the name indicates doesn't publish or subscribe to anything. Registering an eventing provider dependency, will override the NullEventing with the configured eventing provider implementation.


Clone this wiki locally