alexandrubau/messenger-azure-queue-transport
## Getting Started
Install the package via Composer:
```bash
composer require alexandrubau/messenger-azure-queue-transport
Publish the configuration file (if needed):
php artisan vendor:publish --provider="AlexandruBau\MessengerAzureQueueTransport\AzureQueueTransportServiceProvider"
Register the Azure Queue transport in config/messenger.php:
'connections' => [
'azure' => [
'driver' => 'azure-queue',
'connection' => 'azure',
'queue' => env('AZURE_QUEUE_NAME'),
'redelivery_enabled' => env('AZURE_REDELIVERY_ENABLED', true),
// ... other config
],
],
First use case: Dispatch a job with Azure Queue transport:
dispatch(new YourJob)->onQueue('azure');
Use the Azure Queue transport for reliable job dispatching:
// Dispatch a job to Azure Queue
dispatch(new ProcessPayment)->onQueue('azure');
// Dispatch with delay (uses Azure Queue's visibility timeout)
dispatch(new ProcessPayment)->delay(now()->addMinutes(5))->onQueue('azure');
Leverage the new RedeliveryStamp support for failed jobs:
// Configure redelivery in config/messenger.php
'connections' => [
'azure' => [
'driver' => 'azure-queue',
'redelivery_enabled' => true,
'redelivery_delay' => 60, // seconds
'max_redeliveries' => 3,
],
],
// Jobs will automatically retry on failure with exponential backoff
Process jobs in batches using Azure Queue's peek/dequeue operations:
// In a worker script or scheduled job
$jobs = app(\AlexandruBau\MessengerAzureQueueTransport\AzureQueue::class)
->getConnection()
->peekMessages(env('AZURE_QUEUE_NAME'), 10);
foreach ($jobs as $job) {
try {
$job->handle();
$job->delete(); // Remove from queue after success
} catch (\Exception $e) {
$job->updateVisibility(300); // Make visible again after 5 mins
}
}
Track job progress via Azure Portal or custom logging:
// Log job dispatch events
event(new JobDispatching($job));
RedeliveryStamp for failed jobs, enabling automatic retry logic.redelivery_enabled is set to true in your connection config.redelivery_delay and max_redeliveries).'azure' => [
'driver' => 'azure-queue',
'log_level' => \Microsoft\Azure\Storage\Blob\BlobRestProxy::LOG_LEVEL_BASIC,
],
AzureQueue class and implementing custom retry logic in your job's handle() method.JobFailed events to implement custom failure handling:
public function handle(JobFailed $event)
{
if ($event->connectionName === 'azure') {
// Custom logic for Azure Queue failures
}
}
NO_UPDATE_NEEDED would not apply here due to the new `RedeliveryStamp` feature warranting an updated assessment.
How can I help you explore Laravel packages today?