rebusazure-storage-queues

Rebus for Azure Storage queue - adjusting frequency between each GetMessage() call


Hello all (and most probably @mookid8000),

I am using Rebus C# library with Azure Storage queue. Everything works fine, just have one issue with logging.

Rebus is making several GetMessage calls to queue per second. That is extremely problematic, because it generates GB of data per day if "queue" operations are being logged to Log Analytics, which cost a lot money.

Is there a way to tell rebus to check the queue only each 10s, or each minute if last response return no new messages? My app doesn't need fast message handling, so slower refresh period between each call to queue is preferable anyway.

Maybe it can be configured somewhere here?

services.AddRebus((configure, sp) => configure
                    .Transport(t =>
                    {
                        CloudStorageAccount storageAccount = CloudStorageAccount
                          .Parse(Configuration.GetValue<string>("StorageQueue:ConnectionString"));
                        t.UseAzureStorageQueues(storageAccount, "queue");
                    })
                    .Routing(r =>
                    {
                        var routing = r.TypeBased();                        
                        routing.Map<TrackedObject>("queue");
                    })
                );

I was checking if I can found some documentation about this, but could not found anything :(

Thank you for any help.


Solution

  • You're looking for how to configure Rebus' back-off times 🙂

    With it, you could do something like this

    services.AddRebus(
        configure => configure.
            .(...)
            .Options(o => {
                o.SetBackoffTimes(
                    TimeSpan.FromSeconds(1),
                    TimeSpan.FromSeconds(2),
                    TimeSpan.FromSeconds(10)
                );
            })
    );
    

    and have it wait 10 s between polling for messages after 3 seconds of running idle.