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

Ensure queue name is added into dynamic job when adding recurring job using AddOrUpdateDynamic and using queue parameter #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timpikelmg
Copy link

As noted in this issue 2259 when using AddOrUpdateDynamic to add a recurring job using DynamicJobs and setting the queue name via the parameter as recommended, the job does not run on the queue unless the Queue attribute is included in the job class/method or the Queue is set in the DynamicRecurringJobOptions.

manager.AddOrUpdateDynamic<INewsletterService>(
    "monthly-newsletter",
    x => x.SendMonthly(),
    Cron.Monthly(),
    new DynamicRecurringJobOptions()
    {
        Filters = new [] { new MyFilterAttribute("newsletter") },
        TimeZone = TimeZoneInfo.Local
    });

The above will run on the default queue.

This appears to be caused by when the DynamicJob is created it is not indicating which job to run on in the FromExpression, ie. return Job.FromExpression(() => DynamicJob.Execute(dynamicJob, default)); so it runs on the default queue unless one of the other ways to set the queue is used.

This changes the ToDynamicJob method so it will create the job to run and include the queue name so the dynamic job will run on the desired queue if it is set in the job.

…lude the queue name so the dynamic job will run on the desired queue if it is set in the job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants