Open sebitsi opened 5 years ago
Re-queueing logic will work fine, if you are specifying a target queue by using the Queue
attribute:
[Queue("critical")]
public void MyMethod() { /* ... */ }
It will also work fine, when you are using the AdvancedQueue
attribute from this gist to dynamically choose a queue based on job arguments. In this case, concrete queue will be calculated by using the String.Format(pattern, job.Args)
method. And this feature will be merged into 1.7.0's QueueAttribute
.
[AdvancedQueue("tenant:{0}")]
public void MyMethod(int tenantId) { /* ... */ }
Other methods don't give stable results, but this is due to the historical reasons – Hangfire's jobs don't relate to any queue, the queue is specified for the concrete job state only, and is lost, when job is moved to another state. Though I agree this should be better documented.
Whops, wrong button
@odinserj I'm trying to add queues (and enqueue jobs into them) dynamically during the runtime of my app, is that possible with something like this?
Essentially, I'm trying to do this:
var state = new EnqueuedState
{
Queue = tenantData.TenantId
};
_backgroundJobClient.Create<MyJob>(
myJob => myJob.RunThing(
tenantData,
Guid.NewGuid().ToString(),
CancellationToken.None),
state);
but this never works because the tenantData.TenantId
wasn't set up at startup, and so the job never processes.
I also wrote on https://discuss.hangfire.io/t/dynamic-queues/121/8 to describe the issue.
Thanks in advance for any help you can provide
seems like my ask is a duplicate of https://github.com/HangfireIO/Hangfire/issues/846. Has there been any progress on this issue? It is pretty much required for my use case.
Hi @odinserj
if we re-queue succesfuly finished job on dashboard, this job is put into default queue regardless main (finished) job is not from default queue.
Is this OK ?