Skip to main content

Sending Notifications: Scheduled Job

Premium
4 min read

Comments & Discussion

HN
Huy Nguyen ✓ Link copied!

Hi, I have some questions as below:

  1. Why don't you use "retry" feature in Job class, for example, add public $tries = 5 to Job class and let laravel handle the rest. Then instead of calling $this->fail(), we can release the job manually to the queue to retry later.
  2. In this lesson, which queue driver are you using? Laravel support many driver such as database, redis.....
  3. I don't see how to setup cron entry (to trigger the scheduler every minute) and supervisor to manage the queue worker. It would be great if you can include the guide on how to setup these tool and queue driver.
  4. In SendScheduledNotificationsCommand class, I think we can use chunkById method to fetch the data, it will help to reduce the memory usage, avoid out of memory in case there are a lot of records in database
M
Modestas ✓ Link copied!

Hi,

  1. I have implemented a custom logic here to track the attempts on the notification itself and stop it manually. While it can be done with tries, it might not be what is expected and this way, you can for example change the retries amount on the fly. For example, change the config call to database settings table call and you can define per-notification retries, which is quite great.
  2. To be fully honest, it usually does not matter. There are some specifics but by default a standard is either database or redis. In our case it was redis
  3. Setting up the queue workers/scheduler are dependant on your deployment process and server you are using. Some people might run it via Forge, others might run it via something else. This would make the section huge, and honestly it is quite clear on documentation in Laravel itself.
  4. That might be a good addition here, but not sure if majority of people need it or would understand what it does :)

In any case, thanks for the feedback! We'll see what we can adjust and I'll let you know if we do!

R
Rishikant ✓ Link copied!

Hi, does the system keep sending notifications automatically or do we need to do more setups to send these notifications? Thanks

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.