Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Send an email notification when a job is broken #436

Merged

Conversation

emteknetnz
Copy link
Collaborator

@emteknetnz emteknetnz commented Jun 24, 2024

Issue #435

There is an email sent for 'stalled' jobs, however there is not an email sent for 'broken' jobs. There is existing logic to ensure that there is only a single notification sent, however no email is actually sent, instead the only notification goes to the logger. An inline comment says "email" so looks like the intention all along was to send an email.

Testing steps

Create a vanilla install of silverstripe/installer + this PR

_config/myemail.yml

---
Name: myemail
After:
  - '#project-emailconfig'
---
SilverStripe\Control\Email\Email:
  admin_email:
    [email protected]: 'Admin-email'
# + something to setup mailhog / mailcatcher / etc

MyBrokenJob.php

<?php

use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
use Symbiote\QueuedJobs\Services\QueuedJob;

class MyBrokenJob extends AbstractQueuedJob
{
    public function getTitle()
    {
        return 'My broken job';
    }

    public function getJobType() {
        return QueuedJob::QUEUED;
    }

    public function process()
    {
        throw new Exception('MY BROKEN JOB EXCEPTION');
    }
}

In admin/queuedjobs create a new 'My broken job'

In console:
vendor/bin/sake dev/tasks/ProcessJobQueueTask
vendor/bin/sake dev/tasks/CheckJobHealthTask

There should be an 'Broken job' email that was sent

@emteknetnz emteknetnz force-pushed the pulls/5/broken-job-email branch from 405bd43 to 41a4d4f Compare June 24, 2024 02:17
@emteknetnz emteknetnz force-pushed the pulls/5/broken-job-email branch from 41a4d4f to bcb57f1 Compare June 24, 2024 02:20
Copy link
Collaborator

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well locally, just a couple of small things to fix.

src/Services/QueuedJobService.php Outdated Show resolved Hide resolved
src/Services/QueuedJobService.php Outdated Show resolved Hide resolved
@emteknetnz emteknetnz force-pushed the pulls/5/broken-job-email branch from bcb57f1 to 46f7e73 Compare June 26, 2024 04:39
templates/QueuedJobsBrokenJobs.ss Outdated Show resolved Hide resolved
src/Services/QueuedJobService.php Outdated Show resolved Hide resolved
src/Services/EmailService.php Show resolved Hide resolved
@emteknetnz emteknetnz force-pushed the pulls/5/broken-job-email branch from 46f7e73 to c515429 Compare June 27, 2024 02:38
src/Services/QueuedJobService.php Outdated Show resolved Hide resolved
@emteknetnz emteknetnz force-pushed the pulls/5/broken-job-email branch from c515429 to dbbcd67 Compare June 27, 2024 03:06
Copy link
Collaborator

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GuySartorelli GuySartorelli merged commit 9ee0863 into symbiote:5 Jun 27, 2024
9 checks passed
@GuySartorelli GuySartorelli deleted the pulls/5/broken-job-email branch June 27, 2024 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants