Skip to content

Handler

Bernardo Teixeira edited this page Oct 22, 2021 · 1 revision

To handle each message, you need to create a handler. You have to implement the interface IEventHandler.

Example

  public class EventFromMicroserviceAHandler : IEventHandler<EventFromMicroserviceA>
    {
        public async Task Handler(EventFromMicroserviceA _event)
        {
            string eventReceive = JsonConvert.SerializeObject(_event);
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\MicroserviceB\EventMessage.txt", true))
            {
                await file.WriteLineAsync(eventReceive);
            }
        }
    }

EventFromMicroserviceAHandler