Skip to content

Publish Message

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

To publish your message can DI the IEventBus interface.

 private readonly IEventBus _eventBus;
 public WeatherForecastController(IEventBus eventBus)
 {
      _eventBus = eventBus;
 }

Call the Publish method when you need it.

  _eventBus.Publish(new EventFromMicroserviceA()
            {
                Message = Summaries[rng.Next(Summaries.Length)],
                Name="test01"
            });

Example