en en en en en en en en en en en en en en en da en en en en en en en en en en en en en en pt en en en sv fr fr en en en en en
You can also create custom channels to store the events in anywhere that you need. For instance in a database, Azure blob storage and etc.
When events are raised, you can receive signals in two forms:
Free text form (via GenericTraceEvent)
In a custom channel, you can listen to events in two ways:
Using Write and WriteLine override of TraceListener. In these methods, the custom listener receives messages in a string with JSON structure or some other free text format if GenericTraceEvent is raised.
using FlexRule.Server.Events; class MyCustomListener : TraceListener { public MyCustomListener() { } public override void Write(string message) { // message of the channel to process } public override void WriteLine(string message) { // message of the channel to process } }
The channel can listen to specific events, using configuration or using your code. For using code, the DomainEvents.Register should be used to subscribe to an event. In this approach, the custom listener receives signals as .Net Types.
using FlexRule.Server.Events; class MyCustomListener : TraceListener { public MyCustomListener() { // TYPE_OF_EVENT is the event type // Subscribe to an event... DomainEvents.Register(typeof(TYPE_OF_EVENT), eventHander); // when the event occurs, the eventHandler is called. } private void eventHander(TYPE_OF_EVENT domainEvent) { // TYPE_OF_EVENT is the event type which this listener is subscribed to } public override void Write(string message) { // Do nothing } public override void WriteLine(string message) { // Do nothing } }
In the sample code above, TYPE_OF_EVENT is the place holder for the actual event type with the names that are listed in the section above.
Once the custom channel is derived from TraceListener, then to register a custom channel, use the configuration on Master and/or Agents and configure them as shown below: