Skip to content

Commit 286f9e3

Browse files
committed
#12 Update to readme
1 parent a67d838 commit 286f9e3

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,55 @@ A Laravel package for real-time monitoring of queues with stats on processing ti
2828

2929
---
3030

31+
## Usage
32+
1. Queue Monitoring Dashboard
33+
Once installed, the package provides a monitoring dashboard accessible at `/queue-monitor` (or a custom route specified in `config/queue-monitor.php`). The dashboard displays:
34+
- The list of queues being monitored.
35+
- The number of jobs processed.
36+
- The number of failed jobs.
37+
- The average processing time for each queue.
38+
2. Automatically Updating Queue Statistics
39+
To update queue statistics after job processing:
40+
- Inject the `QueueMonitorService` into your job classes or relevant services.
41+
- Use the `updateQueueStatus` method to log the queue name, processing time, and failure status.
42+
Example Integration in a Job:
43+
```php
44+
use MattYeend\QueueMonitoring\Services\QueueMonitorService;
45+
46+
class ExampleJob implements ShouldQueue
47+
{
48+
public function handle(QueueMonitorService $service)
49+
{
50+
$queueName = 'example-queue';
51+
$startTime = microtime(true);
52+
53+
try {
54+
// Performs job processing
55+
} catch (\Exception $e) {
56+
$service->updateQueueStatus($queueName, 0, true); // Log a failed job
57+
throw $e;
58+
}
59+
60+
$endTime = microtime(true);
61+
$processingTime = ($endTime - $StartTime) * 1000; // Convert to milliseconds
62+
$service->updateQueueStatus($queueName, $processingTime, false); // Log a successful job
63+
}
64+
}
65+
```
66+
3. Customising the Dashboard
67+
You can customise the dashboard view by modifying the published Blade file
68+
`resources/views/vendor/queue-monitor/dashboard.blade.php`
69+
4. Custom Route
70+
The change the route for the dashboard, edit the `dashboard_route` value in the configuration file
71+
`'dashboard_route' => '/admin/queue-status'`
72+
5. Notifications for Failed Jobs
73+
To enable email notifications for failed jobs:
74+
- Add the following to your `.env` file:
75+
76+
- The configured email address will receive alerts whenever a job fails in a monitored queue.
77+
78+
---
79+
3180
## Configuration
3281
### `.env` File
3382
To configure email notifications for failed jobs, add the following line to your `.env` file:

0 commit comments

Comments
 (0)