-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Impossible to fetch jobs when using conventions on discriminator #328
Comments
Thank you for submitting this. I will look into a solution. |
Kindly try adding this configuration to your codebase: ConventionRegistry.Register(
"Hangfire Mongo Conventions",
new ConventionPack
{
new DelegateClassMapConvention("Set Hangfire Mongo Discriminator", cm =>
cm.SetDiscriminator(cm.ClassType.Name))
},
t => t.FullName.StartsWith("Hangfire.Mongo.Dto")); |
Just to give you some feedback. So it seems to work but it feels like a workaround at the moment. |
Thank you for your feedback. Would initialization be easier if this was embedded in the Hangfire Mongo bootstrapper code? The challenge is that to comply to the "WriteOnlyTransaction" API defined in the Hangfire.Core lib I have to work directly on BsonDocuments. Hangfire.Mongo also needs the "HierarchicalDiscriminatorConvention" as other parts of the code. I will look into making this library more resilient against other serializer conventions |
use manual serialization. this avoids conflict with serializer conventions #328
* use manual serialization use manual serialization. this avoids conflict with serializer conventions #328 * remove not used convention * minor optimization of type casting
Our conversation triggered a minor re-write. Im now manually serializing the DTO's which should make it immune to any convention there might be used. Thanks for your input |
Please let me know if your issue has been resolved. Then I'll close this issue. Thanks! |
closing due to inactivity |
Hi,
I have an external library that sets this kind of convention:
classMap.SetDiscriminator(classMap.ClassType.FullName);
in Hangfire.Mongo, MongoWriteOnlyTransaction -> CreateExpiredJob, jobDto.ToBsonDocument() is called and that makes it so that the types for the job are serialized using the fully qualified name:
{ ... "_t": [ "Hangfire.Mongo.Dto.BaseJobDto", "Hangfire.Mongo.Dto.ExpiringJobDto", "Hangfire.Mongo.Dto.JobDto" ], ... }
The problem is that most of the other code in MongoWriteOnlyTransaction writes "_t" as follows:
["_t"] = new BsonArray {nameof(BaseJobDto), nameof(ExpiringJobDto), nameof(KeyJobDto), nameof(CounterDto)},
making the stored data have different kind of values:
Other than that, the BsonDiscriminator is also set as the nameof of the class:
[BsonDiscriminator(nameof(SetDto))]
In this configuration my project isn't working because I guess that OfType is using the discriminator convention that I've mentioned in the beginning and so it doesn't find any set.
I think that the writer class should be updated to serialize all the discriminators based on the conventions.
The text was updated successfully, but these errors were encountered: