Is it possible change quartz.dataSource.myDS.connectionString when the apps is running? #1863
Unanswered
guillermo2007
asked this question in
General
Replies: 2 comments 9 replies
-
You need to create a scheduler per connection string. You can configure it with |
Beta Was this translation helpful? Give feedback.
5 replies
-
Hello Marko, I have a problem, I have two pieces of code:
public async Task<IScheduler> GetSchedulerSelected()
{
try
{
using var scope = serviceScopeFactory.CreateScope();
var coreSchedulerDbContext = scope.ServiceProvider.GetRequiredService<CoreSchedulerDbContext>();
var tenant = await coreSchedulerDbContext.Tenants.FirstOrDefaultAsync(x => x.Selected);
if (tenant == null )
throw new TenantNotFoundException();
if (string.IsNullOrEmpty(tenant.ConnectionString))
throw new TenantHasNotConnectionStringException();
var properties = new NameValueCollection
{
["quartz.scheduler.instanceName"] = tenant?.Name,
["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz",
["quartz.jobStore.useProperties"] = "false",
["quartz.jobStore.performSchemaValidation"] = "false",
// "json" is alias for "Quartz.Simpl.JsonObjectSerializer, Quartz.Serialization.Json"
["quartz.serializer.type"] = "json",
["quartz.jobStore.dataSource"] = "default",
["quartz.dataSource.default.connectionString"] = tenant.ConnectionString,
["quartz.dataSource.default.provider"] = "SqlServer"
};
ISchedulerFactory schdFactory = new StdSchedulerFactory(properties);
return await schdFactory.GetScheduler();
}
catch (Exception)
{
throw;
}
} 2.-The next step is to get JobGroupNames and it doesn't return nothing, on the other hand, when i instance IScheduler by ISchedulerFactory, the methods return some data. public async IAsyncEnumerable<ScheduleModel> GetAllJobsAsync(ScheduleJobFilter? filter = null)
{
var schedulerCustom = await scheduleCustomFactory.GetSchedulerSelected();
var jobGroupNames = await schedulerCustom.GetJobGroupNames();
foreach (var jobGrp in jobGroupNames)
{
if (filter != null && !filter.IncludeSystemJobs)
{
if (jobGrp == Constants.SYSTEM_GROUP)
continue;
}
var jobKeys = await schedulerCustom.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(jobGrp));
foreach (var jobKey in jobKeys)
{
await foreach (var job in GetScheduleModelsAsync(jobKey))
{
yield return job;
}
}
}
} Do you know why? Thanks |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone
Is there any possibility to change the connection string from AdoJobStore in SqlServer when the application is running?
My idea is to have some databases in SqlServer and create a web application that can be administrate the jobs of each database.
For this, i need to change the instance to database when the user selected the other one
Any idea?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions