Skip to content

A NuGet Package for bootstrapping .NET SuperBootstrapBase microservices with ready-to-use Event/Queue utilities which implements logging/tracing out of the box. ๐Ÿš

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE.md
Notifications You must be signed in to change notification settings

mrkresnofatih/SuperBootstrapEvent

Repository files navigation

DesertCamel.BaseMicroservices.SuperBootstrap.Event

Get Started

  1. Setup a working SuperBootstrapBase NuGet Package and configuration for your WebAPI project. Learn more
  2. Install the SuperBootstrapEvent NuGet Package.
  3. Add the following configuration in your appsettings.json file:
{
    // other settings
    "SuperBootstrap": {
        // other superbootstrap settings
        "Event": {
            "Selected": "RabbitMq",
            "Options": {
                "RabbitMq": {
                    "HostName": "localhost",
                    "UserName": "guest",
                    "Password": "guest",
                    "Port": 5672,
                    "ExchangeName": "ex"
                }
            }
        }
    }
}
  1. In your controller class, you implement your publishers and/or your subscribers as follows:
    public WeatherForecastController(ILogger<WeatherForecastController> logger, 
        ISuperBootstrapEventPublisher superBootstrapPublisher, 
        ICorrelationIdUtility correlationIdUtility)
    {
        _logger = logger;
        _superBootstrapPublisher = superBootstrapPublisher;
        _correlationIdUtility = correlationIdUtility;
    }

    [HttpGet("publish1")]
    public async Task<ActionResult> PublishOne()
    {
        await _superBootstrapPublisher.PublishAsync(new SuperBootstrapEventPublishRequest
        {
            ObjectMessage = new DummyObject { Name = "ikan", Number = 123 },
            CorrelationId = _correlationIdUtility.Get(),
            TopicName = "event1"
        });
        return Ok();
    }

    [NonAction]
    [SuperBootstrapEventSubscribe("event1")]
    public void SubscriberOne(EventMessage eventMessage)
    {
        _logger.LogInformation($"1 -> {eventMessage.JsonMessage}");
    }
  1. In your startup class, implement the superbootstrap event extension method:
public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            // other services

            services.AddBootstrapBase(Configuration);
            services.AddBootstrapEvent(Configuration); // add this
        }

        // other
    }
}

About

A NuGet Package for bootstrapping .NET SuperBootstrapBase microservices with ready-to-use Event/Queue utilities which implements logging/tracing out of the box. ๐Ÿš

Topics

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages