Closed Lexy2 closed 6 months ago
That's interesting and it seems clearly linked to #142. All of the monitoring API relies on GetJobsWithProperties to fetch history data, do you find the problem with all methods ? (FailedJobs, SucceededJobs, ProcessingJobs etc)
Nope, this is just for ScheduledJobs. The reason is that other states have implemented handlers in the storage. I'll have a crack at it, the problem seems a bit deeper.
Actually, misread your comment. All the monitoring API methods do not return the queue. It's only mentioned in history. It may be linked, yes.
We agree that Job.Queue
is where the queue is supposed to be and static Job RedisMonitoringApi.TrytoGetJob
is used to return the job. In turn, that method only take string type, string method, string parameterTypes, string arguments
and passes these values to the overload of InvocationData
constructor that doesn't take a Queue
as input.
If we use the cosntructor that take the queue, the corresponding Queue prop of the job would be valorized with passed queue value.
So the problem boils down about how to pass that argument to the InvocationData constructor. In turns, it depends on the values that are loaded from Redis, and here I was wrong, those are not loaded only through "GetJobsWithProperties" but also through "ScheduledJobs" and "JobDetails". Basically the three reference of RedisMonitoringApi.TryToGetJob
.
I believe we should add a string queue
parameter to this method, modify it to pass that argument to the InvocationData constructor and above all modify the three reference of RedisMonitoringApi.TryToGetJob
so to pass the correct value for the new arg.
Definitely a bug.
Apparently, this particular issue is not related to #137 or #142.
The "Queue": "default"
hash entry comes from the primary EnqueuedState
constructor - see Hangfire/EnqueuedState.cs, and is set to default
regardless of what's specified in the job.
However, this value is used if the job does not specify a queue (i.e. storage doesn't support Queue
property, or Enqueue
is called without specifying the queue explicitly).
We could potentially implement an EnqueuedStateHandler
that would strip this property from the state to avoid confusion. But I'm not sure how this is used in the wild - maybe QueueAttribute
depends on it and such?
With the fix of #137 I'm happy to just ignore this issue.
Steps to repro:
default
.Expected: History data contains
"Queue": "<queue-name>"
Actual: History data contains
"Queue": "default"