AymDev / MessengerAzureBundle

A Symfony 4/5/6 bundle providing a Messenger transport for Azure Service Bus using the Azure REST API.
MIT License
10 stars 7 forks source link

Generate SAS token for every request #1

Closed pepamartinec closed 2 years ago

pepamartinec commented 2 years ago

Currently a SAS token is generated by AzureHttpClientConfigurationBuilder when AzureTransport is created, with default 1 hour expiration time. That basically means that when I run bin/console messenger:consume, it can run for 1 hour and then fails with 403 error, because the SAS token expires.

This change moves the token generation into the HTTP client, so a new token is generated for each request, allowing the consumer to run indefinitely (in theory).

AymDev commented 2 years ago

Hello and thanks a lot for your PR !

I think that the message consumption should have a time limit (as stated in the docs) but you're right. I was wondering about a potential limit for SAS tokens, it looks like there is none and renewing them early is a good practice.

I like very much your refactoring about token generation and DSN parsing, thanks for that too. I'm merging this and I'll release a new minor version very soon.