Listening
Setting up Wolverine listeners and GCP Pub/Sub subscriptions for GCP Pub/Sub topics is shown below:
cs
var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.UsePubsub("your-project-id");
opts.ListenToPubsubTopic("incoming1");
opts.ListenToPubsubTopic("incoming2")
// You can optimize the throughput by running multiple listeners
// in parallel
.ListenerCount(5)
.ConfigurePubsubSubscription(options =>
{
// Optionally configure the subscription itself
options.DeadLetterPolicy = new DeadLetterPolicy
{
DeadLetterTopic = "errors",
MaxDeliveryAttempts = 5
};
options.AckDeadlineSeconds = 60;
options.RetryPolicy = new RetryPolicy
{
MinimumBackoff = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)),
MaximumBackoff = Duration.FromTimeSpan(TimeSpan.FromSeconds(10))
};
});
}).StartAsync();