Get notified when a queued job fails

Overview

Get notified when a queued job fails

Latest Version on Packagist Test Status Software License Build Status StyleCI Total Downloads

This package sends notifications if a queued job fails. Out of the box it can send a notification via mail and/or Slack. It leverages Laravel's native notification system.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

For Laravel versions 5.8 and 6.x, use v3.x of this package.

You can install the package via composer:

composer require spatie/laravel-failed-job-monitor

If you intend to use Slack notifications you should also install the guzzle client:

composer require guzzlehttp/guzzle

The service provider will automatically be registered.

Next, you must publish the config file:

php artisan vendor:publish --tag=failed-job-monitor-config

This is the contents of the default configuration file. Here you can specify the notifiable to which the notifications should be sent. The default notifiable will use the variables specified in this config file.

return [

    /**
     * The notification that will be sent when a job fails.
     */
    'notification' => \Spatie\FailedJobMonitor\Notification::class,

    /**
     * The notifiable to which the notification will be sent. The default
     * notifiable will use the mail and slack configuration specified
     * in this config file.
     */
    'notifiable' => \Spatie\FailedJobMonitor\Notifiable::class,

    /**
     * The channels to which the notification will be sent.
     */
    'channels' => ['mail', 'slack'],

    'mail' => [
        'to' => '[email protected]',
    ],

    'slack' => [
        'webhook_url' => env('FAILED_JOB_SLACK_WEBHOOK_URL'),
    ],
];

Configuration

Customizing the notification

The default notification class provided by this package has support for mail and Slack.

If you want to customize the notification you can specify your own notification class in the config file.

// config/laravel-failed-job-monitor.php
return [
    ...
    'notification' => \App\Notifications\CustomNotificationForFailedJobMonitor::class,
    ...

Customizing the notifiable

The default notifiable class provided by this package use the channels, mail and slack keys from the config file to determine how notifications must be sent

If you want to customize the notifiable you can specify your own notifiable class in the config file.

// config/laravel-failed-job-monitor.php
return [
    'notifiable' => \App\CustomNotifiableForFailedJobMonitor::class,
    ...

Usage

If you configured the package correctly, you're done. You'll receive a notification when a queued job fails.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

A big thank you to Egor Talantsev for his help creating v2 of the package.

License

The MIT License (MIT). Please see License File for more information.

Comments
  • [IMPROVEMENT] Now this package using Laravel 5.3 notification

    [IMPROVEMENT] Now this package using Laravel 5.3 notification

    In raising this pull request, I confirm the following (please check boxes):

    • [x] I have read and understood the contributors guide.
    • [x] I have checked that another pull request for this purpose does not exist.
    • [x] I have considered, and confirmed that this submission will be valuable to others.
    • [x] I have added tests to prove that the code in this PR works.

    Description

    This PR for #11 .

    Let me tell how it's works.

    You can install new version and if your app suits next requirements:

    • You have \App\User class
    • You have added scopeCanBeNotifiedAboutFailedJobs method to \App\User. You're ready to use it oit of the box,

    You can publish config and get next abilities:

    • Change Notifiable class
    • Change Notification class
    • Set channels
    • Set criteria method's name for notifiables

    Also you can add additional notifications. For example what it you send very important email to your customer and if fails... Of course developers will get this error, but also we can setup ability to notify about this issue our sale merchant without any technical information, just to inform responsible person for client that something went wrong, so you can add to config next lines:

    'App\Jobs\SendImportantEmail' => [
        'notifiable' => \App\User::class,
        'notification' => \Spatie\FailedJobMonitor\Notification::class,
        'via' => ['mail'],
        //'filter' => 'canBeNotifiedAboutFailedJobs'
    ],
    

    And App\Jobs\SendImportantEmail job will fail * and App\Jobs\SendImportantEmail will be used for notification.

    So I think this solution is flexible:

    • You're not attached to notifiable entity
    • You can easily customize notification
    • You can notify not only developers but users too about some important issues without any sensitive data.

    All data (exception and payload) are sening as attachment via email.

    I'm ready to hear your option, @freekmurze

    opened by spyric 5
  • **[FEATURE]** Allows to configure a custom view for the e-mail notification

    **[FEATURE]** Allows to configure a custom view for the e-mail notification

    In raising this pull request, I confirm the following (please check boxes):

    • [x] I have read and understood the contributors guide.
    • [x] I have checked that another pull request for this purpose does not exist.
    • [x] I have considered, and confirmed that this submission will be valuable to others.
    • [x] I have not added tests to prove that the code in this PR works. E-mail tests are already there.

    Description

    This patch allows one to configure a custom view for the e-mail notification.

    opened by emielmolenaar 5
  • Laravel 8.x Compatibility

    Laravel 8.x Compatibility

    This is an automated pull request from Shift to update your package code and dependencies to be compatible with Laravel 8.x.

    Before merging, you need to:

    • Checkout the l8-compatibility branch
    • Review all comments for additional changes
    • Thoroughly test your package

    If you do find an issue, please report it by commenting on this PR to help improve future automation.

    opened by laravel-shift 4
  • WIP add ability to throttle failure notifications

    WIP add ability to throttle failure notifications

    This code is entirely untested, but I wanted to open the PR to see if there is interest in adding this functionality. It can also be implemented via a notificationFilter, but I thought maybe this should be provided out of the box.

    If there is interest, I can look into adding tests and making sure it actually works :)

    Backstory: Yesterday I deployed broken code and ended up sending out 400 emails to our internal engineering mailing list :)

    opened by lsmith77 3
  • Make compatible with Laravel 5.3

    Make compatible with Laravel 5.3

    Various queue job events such as JobProcessing, JobProcessed and JobFailed no longer contain the $data property. Should use $event->job->payload() to get the equivalent data.

    opened by tonning 2
  • Allow multiple email addresses

    Allow multiple email addresses

    Thank you for this great package. It has really nice features that are very useful for developers. I was just wondering if would it be nice to have the possibility to define more than one email address.

    This may break backward compatibility because the returning type of routeNotificationForMail method has been changed. It would be nice if this feature can be part of the next major release if it's possible.

    Let me know if you have any questions.

    Thanks!

    opened by stfndamjanovic 1
  • Improve documentation on notifications filter.

    Improve documentation on notifications filter.

    Using a closure in the notifications filter results in an error as they are not serializable. This pull request documents the better approach of using callables.

    Resolves https://github.com/spatie/laravel-failed-job-monitor/issues/55

    opened by ngunyimacharia 1
  • Add PHP 8-only Support (v4)

    Add PHP 8-only Support (v4)

    This PR adds a new major version, v4.0.0.

    Specifically, it:

    • Removes support for all PHP 7.x versions.
    • Requires PHP 8.0+.
    • All syntax converted to PHP 8 where possible.
    • Removes unnecessary PHP docblocks per Spatie's guidelines.
    • Removes Laravel v6 & v5.8 support.
    • Implements spatie/laravel-package-tools.
    • Updates the changelog - release date needs to be updated, currently is "unreleased".
    opened by patinthehat 1
  • allows extension of illuminate notification class

    allows extension of illuminate notification class

    When developing using this package, I wanted to add a new notification type. So I created a new class an extened the \Illuminate\Notifications\Notification class however I received an error stating the new class I made had to extend the Illuminate\Notifications\Notification class, which my class was doing.

    A workaround is extending the Spatie\FailedJobMonitor\Notification - however, the error message does not suggest this to be the correct source of action.

    This pull request resolves the issue by importing the Illuminate\Notifications\Notification and uses it in the isValidNotificationClass method.

    opened by Drewdan 1
  • WIP: Add support for laravel 8

    WIP: Add support for laravel 8

    This PR adds support for the upcoming release of laravel 8. Tests are all passing. I excluded php version 7.2 for laravel 8 since laravel itself requires php 7.3

    To get the tests to work I had to set the minimum stability to dev, since laravel 8 is not released yet. This change should probably be reverted before releasing.

    opened by SamuelNitsche 0
Releases(4.2.0)
Owner
Spatie
Webdesign agency based in Antwerp, Belgium
Spatie
Schedule your OLX searches and get notified by email when something new is published 📆

Olx.ba search scheduler Missing scheduler for Olx.ba searches. Production-ready small web application which notifies you by email when something new i

Benjamin Fajić 8 Nov 8, 2022
Get notified when stuck jobs are detected.

Get notified and execute PHP callback when you have stuck jobs for a defined number of hours. Notifications can be sent by mail, Slack and webhooks (c

Arthur LORENT 5 Aug 22, 2022
Trigger email failures to assert what happens on your Laravel Application when an email fails to send

Laravel Email Failer composer require --dev rogervila/laravel-email-failer About Trigger email failures to assert what happens on your Laravel Applica

Roger Vilà 30 Jul 17, 2022
Laravel Nova's Queued Export As CSV Action

Laravel Nova's Queued Export As CSV Action Installation To install through composer, run the following command from terminal: composer require "nova-k

null 7 Nov 7, 2022
Job Portal - Find your dream job here Various career opportunities await you

Find your dream job here Various career opportunities await you. Find the right career and connect with companies anytime, anywhere ?? free access to search for jobs, post resumes, and research companies. ??

Ossama Mehmood 샘 5 Nov 14, 2022
A library of powerful code snippets to help you get the job done with Gravity Forms and Gravity Perks.

Gravity Wiz Snippet Library Gravity Wiz is creating the most comprehensive library of snippets for Gravity Forms ever. We'll be consistently moving ou

Gravity Wiz 147 Nov 26, 2022
PHP cron job scheduler

PHP Cron Scheduler This is a framework agnostic cron jobs scheduler that can be easily integrated with your project or run as a standalone command sch

Giuseppe Occhipinti 694 Nov 29, 2022
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro

Supporting Enqueue Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and

Enqueue 2.1k Dec 4, 2022
Kirby Janitor job for staging

Simple staging Janitor jobs Plugin for very simple staging setup for https://github.com/bnomei/kirby3-janitor/ (required). Beta quality - use at your

Florian Karsten 8 Nov 27, 2022
Bug bounty tools built in PHP to help penetration tester doing the job

BugBountyTools-PHP Bug bounty tools built in PHP to help penetration tester doing the job Website who using this script: KitaBantu Soon! 403 Bypasser

Muhammad Daffa 7 Aug 17, 2022
Chain Laravel jobs without having to glue it to a starting job

Laravel Job Chainer JobChainer does chain a variable amount of jobs by adding them with the add() method. This makes it possible to chain jobs without

Just Iversen 69 Nov 18, 2022
Task Scheduling with Cron Job in Laravel

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Shariful Islam 1 Oct 16, 2021
Your personal job-search assistant

JobsToMail Your personal job-search assistant About JobsToMail is an open source web application that allows users to sign up to receive emails with j

JobApis 93 Nov 13, 2022
A better way to create complex batch job queues in Laravel.

Relay A better way to create complex batch job queues in Laravel. Installation composer require agatanga/relay Usage Example Let's say you have the fo

Agatanga 10 Sep 15, 2022
Homework assignment for an job opening for PHP developer

favorite_countries Homework assignment for an job opening for PHP developer Description: This app lets registered users to be able to save favourite c

Elena 1 Nov 13, 2021
Job Engelen INF2B 669915 Webdevelopment eindopdracht.

Docker template for PHP projects This repository provides a starting template for PHP application development. It contains: NGINX webserver PHP FastCG

null 0 Jan 9, 2022
Cron Job Manager for Magento 2

EthanYehuda_CronJobManager A Cron Job Management and Scheduling tool for Magento 2 Control Your Cron Installation In your Magento2 root directory, you

Ethan Yehuda 265 Nov 24, 2022
Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people home in decoration positions and others.

Iran-Decoration Platform Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people

AmirHossein Mohammadi 7 Jul 25, 2022
Clean up and prevent empty meta from being saved for Job, Company, or Resume listings in database

=== Empty Meta Cleanup for WP Job Manager === Contributors: tripflex Tags: wp job manager, meta, cleanup, wpjobmanager Requires at least: 5.2 Tested u

Myles McNamara 3 Feb 7, 2022
A PHP-based job scheduler

Crunz Install a cron job once and for all, manage the rest from the code. Crunz is a framework-agnostic package to schedule periodic tasks (cron jobs)

null 50 Nov 28, 2022