Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using an Azure Service Bus Queue and BrokeredMessage.ScheduledEnqueueTimeUtc to renew subscriptions

I have a subscription model, and want to perform renew-related logic like issue new invoice, send emails, etc. For example, user would purchase the subscription today, and the renewal is in a year's time. I've been using an Azure Queue recently, and think it would apply for such a renewal.

Is it possible to use the Azure Queue by pushing messages using BrokeredMessage.ScheduledEnqueueTimeUtc (http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage.scheduledenqueuetimeutc.aspx) for such long term scheduled messages?

I've used it for shorter-term, like sending notifications in 1 minute time and it works great.

This way, I can have even multiple processes listening to the queue, and be sure that only one process would perform the renewal logic. This would solve a lot of locking-related problems, as that is kind of built-in the Azure Queue via leasing and related features.

like image 444
Karl Cassar Avatar asked Feb 11 '23 14:02

Karl Cassar


1 Answers

Yes, you can use it for long-term scheduling, scheduled messages have the same guaranties as normal ones. But there are few things you need to be aware of:

  • ScheduledEnqueueTimeUtc is a time when message is going to be available (within hundreds of miliseconds) on the queue but not necessary delivered, this depends on load and state of the queue. So it's fine for business processes but not for time sensitive (milliseconds) usage. Not a problem in your case, unless your subscription cancellation is really time sensitive.
  • It affects your storage quota ( Not really a problem with current quotas, but if you think about years this might be a problem)
  • As far as I'm aware you can't access scheduled messages before ScheduledEnqueueTimeUtc, they are invisible.

Extremely awesome source of informations on azure messaging

From technological perspective it's fine but in your case I would also think about other potential problems if you think about years:

  • Message versioning
  • What happens when you would like to change Azure to something else (AWS?)
  • What if you decide to change in next year Azure Service Bus for NServiceBus
like image 67
b2zw2a Avatar answered Feb 15 '23 09:02

b2zw2a