squigg / azure-queue-laravel

PHP Laravel Queue Driver package for Microsoft Azure Storage Queues
43 stars 24 forks source link

Make the queue clearable #26

Open rikmorskate opened 2 years ago

rikmorskate commented 2 years ago

Added functionality to make the Azure queue clearable. This will make php artisan queue:clear work.

squigg commented 2 years ago

Thanks for the contribution.

According to the documentation this method can still return 500 error with OperationTimedOut and suggests retrying. Perhaps we should handle this error and continually retry until the clearing has succeeded?

The behaviour of php artisan queue:clear would then be blocking until the queue is actually fully cleared, rather than potentially failing.

rikmorskate commented 2 years ago

How about this?

rikmorskate commented 2 years ago

@squigg What do you think of the solution I implemented?

squigg commented 2 years ago

Hey, sorry for the delay. I think we need to be more specific about the ServiceException being caught here, as this exception can occur for many other reasons beyond just the timeout we are keen to retry on.

I had a quick look and it seems that the code that parses the response in ServiceException doesn't save the code property from the XML error format.

I'm not sure whether the errorText or errorMessage properties would include the OperationTimedOut error code or not, but if they don't then the full XML response is available and we could do a rudimentary check here to confirm whether or not it's failed for a timeout and just retry in that case.