Skip to content

Instantly share code, notes, and snippets.

@viktors-telle
Last active June 14, 2020 18:52
Show Gist options
  • Save viktors-telle/aa554f5bfb9e0b2c37290cbbff59b8d9 to your computer and use it in GitHub Desktop.
Save viktors-telle/aa554f5bfb9e0b2c37290cbbff59b8d9 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
using GreenPipes;
using MassTransit;
namespace Retries
{
internal static class Program
{
static async Task Main(string[] args)
{
var busControl = CreateBusControl();
await StartBusControl(busControl);
}
private static IBusControl CreateBusControl()
{
return Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host("localhost");
cfg.ReceiveEndpoint("message-queue", e =>
{
e.UseMessageRetry(retryConfigurator =>
{
retryConfigurator.Incremental(
3,
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(15)
);
}
);
e.Consumer<Consumer>();
});
});
}
private static async Task StartBusControl(IBusControl busControl)
{
await busControl.StartAsync();
await busControl.Publish<IMessage>(
new Message(Guid.NewGuid().ToString(), "Valid name")
);
Console.WriteLine("Press any key to exit");
await Task.Run(() => Console.ReadKey());
await busControl.StopAsync();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment