Last active
June 14, 2020 18:52
-
-
Save viktors-telle/aa554f5bfb9e0b2c37290cbbff59b8d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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