Developer forum

Forum » Integration » Notification email not sent when running job from scheduled task

Notification email not sent when running job from scheduled task

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a solution with a number of integration jobs that use the OData provider. I also set up email notifications (for failure only) on those jobs. When I run them manually and something fails, the emails gets sent. So far so good.

But running the same job (along with others) using a scheduled task created from the URL builder, the email doesn't get sent; neither on success nor on failure. The job itself runs fine; it's just the notification that is missing.

Bug? Or unsupported scenario? The URL task doesn't have a notification itself, so I am stuck sending emails on errors.

Any suggestions or ideas?

Imar


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I looked into this a bit more and found the following:

1. The notification isn't sent when StopOnFailedJob is true, probably because of this code in JobQueue.cs:

if (jobTask.StopOnFailedJob & !successRate[job])
{
    break;
}
if (isFromScheduledTask)
{
    string logFilePath = jobToRun.LogFileFullPath;
    if (File.Exists(logFilePath))
    {
        foreach (var l in File.ReadAllText(logFilePath).Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
        {
            logger.Log(l);
        }
    }
}
logger.Log($"Finished job - {jobName}.");

if (!jobToRun.NotificationSettings.FailureOnly || !successRate[job])
{
    SendMail(jobToRun, successRate.ContainsValue(false), jobToRun.LogFileFullPath);
}

When exiting from the StopOnFailedJob check it should also send the email I think.

2. The mail isn't sent when I use JobRunnerSynchronized.aspx only when I use JobRunner.aspx. Not sure why that is.

So, I can make it work when I use JobRunner and StopOnFailedJob = false. but I need at least StopOnFailedJob = true and ideally JobRunnerSynchronized.aspx as well.

Thanks!

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Imar,
yes, that is a bug and will be fixed in #16300
BR, Dmitrij

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Dmitrij,

I see that #16300 will fix the issue with StopOnFailedJob. But did you also get a chance to look at JobRunnerSynchronized versus JobRunner where JobRunnerSynchronized doesn't send the notifications but JobRunner does?

Thanks!

Imar

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
I was looking on that but I have not found out any code differences that might be different among those pages, so not sure why it doesn't behave in the same way.
Can you check if maybe some url paramaters are different or smth else is different when the calls are made?
Are the DI jobs even run when you call them via  JobRunnerSynchronized?
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks. It may have been me then :-) I'll do some further digging but for now consider this a non-issue then.

For my understanding, what's the difference between these three job runners:

JobRunner.aspx
JobRunnerBackground.aspx
JobRunnerSynchronized.aspx

I couldn't find anything in the documentation that explains the differences.

Thanks!

Imar

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Imar,
JobRunner.aspx is used to prepare the jobs to be run in a background thread that is calling the JobRunnerBackground.aspx page in a separate thread (asynchronous execution)

JobRunnerBackground.aspx - just adds the jobs to the JobQueue, it is only called from the JobRunner.aspx
JobRunnerSynchronized.aspx - run the jobs in the current thread, so it is used for the synchronous execution
So you shouild use only those 2: JobRunner.aspx or JobRunnerSynchronized.aspx
BR, Dmitrij

Votes for this answer: 1
 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply
This post has been marked as an answer

Hi Imar

The bugfix #16300 regarding data integration job email sending for StopOnFailedJob=true
Now fixed and released in Dynamicweb version 9.16.3

Kind Regard
Dynamicweb Care Support
Kristian Kirkholt

 

Votes for this answer: 1

 

You must be logged in to post in the forum