Skip to content

Instantly share code, notes, and snippets.

@marcioduarte89
Created November 12, 2021 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcioduarte89/a381079dfb2dd18e156ca59aea5d9a83 to your computer and use it in GitHub Desktop.
Save marcioduarte89/a381079dfb2dd18e156ca59aea5d9a83 to your computer and use it in GitHub Desktop.
IProducer registration
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Producer.API", Version = "v1" });
});
services.AddScoped(x =>
{
var bootstrapperServer = Configuration.GetValue<string>("BootstrapperServer");
var producerConfig = new ProducerConfig
{
BootstrapServers = bootstrapperServer,
EnableIdempotence = true,
Acks = Acks.All,
LingerMs = 50
};
return new ProducerBuilder<int, string>(producerConfig).Build();
});
services.AddScoped<ITransactionService, TransactionService>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment