question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ScheduleJob shorthand: Job name should match trigger name by default

See original GitHub issue

Describe the bug

ScheduleJob is documented as a shorthand for AddJob plus AddTrigger, and it is wonderful.

Configuring the trigger is mandatory. Configuring the job is optional. It is, by far, the most readable to omit the job configuration - even the example in the docs omits it.

However, if no job name is explicitly specified, a UUID is generated for it. This seems like a poor default. Consider the example from the docs:

q.ScheduleJob<ExampleJob>(trigger => trigger
    .WithIdentity("Combined Configuration Trigger")
    .StartAt(DateBuilder.EvenSecondDate(DateTimeOffset.UtcNow.AddSeconds(7)))
    .WithDailyTimeIntervalSchedule(x => x.WithInterval(10, IntervalUnit.Second))
    .WithDescription("my awesome trigger configured for a job with single call")
);

The trigger name will be “Combined Configuration Trigger”. What should the job name be? I would infer that, considering what the shorthand was designed for in the first place, the job name should match the trigger name by default.

Version used

3.3.2.

To Reproduce

Simply implement the example from the docs.

Expected behavior

The job name (in the backing store) should equal the trigger name.

Additional Context

The only workaround we currently have is significantly uglier than the example, and seems to somewhat cancel out the benefits of the shorthand:

q.ScheduleJob<ExampleJob>(trigger => trigger
    .WithIdentity("Combined Configuration Trigger")
    .StartAt(DateBuilder.EvenSecondDate(DateTimeOffset.UtcNow.AddSeconds(7)))
    .WithDailyTimeIntervalSchedule(x => x.WithInterval(10, IntervalUnit.Second))
    .WithDescription("my awesome trigger configured for a job with single call"),
    job => job.WithIdentity("Combined Configuration Trigger")
);

More importantly, it violates the DRY (Don’t Repeat Yourself) principle. We could store the job name in a variable or constant, but that would require even more code.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
lahmacommented, Jul 29, 2021

Thanks for the discussion and a great PR to improve things!

1reaction
lahmacommented, Jul 29, 2021

@Timovzl please use a fork, it’s quite standard way as I cannot allow full write access to this repo for everyone. Using a PR allows us to discuss the implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing the name of a Quartz.NET job or trigger before ...
Since I need unique names for each job/trigger, I was basically going to take the template job's name like "SomeJob" to "SomeJob01" when...
Read more >
Quartz Scheduler Developer Guide
The default JobFactory simply calls newInstance() on the job class, then a empts to call se er methods on the class...
Read more >
https://raw.githubusercontent.com/quartznet/quartz...
(#1236) * ScheduleJob shorthand: Job name should match trigger name by default (#1211) * CronTriggerImpl.WillFireOn returns wrong result when TimeZone is ...
Read more >
Scheduler (Quartz Parent POM 2.1.7 API)
Job s and Trigger s have a name and group associated with them, which should uniquely identify them within a single Scheduler ....
Read more >
Get-JobTrigger (PSScheduledJob) - PowerShell
The Get-JobTrigger cmdlet gets the job triggers of scheduled jobs. You can use this command to examine the job triggers or to pipe...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found