michaelklishin / quartz-mongodb

A MongoDB-based store for the Quartz scheduler. This fork strives to be as feature complete as possible. Originally by MuleSoft.
Other
248 stars 203 forks source link

quartz-mongodb and axonframework don't work together #97

Closed levi-h closed 9 years ago

levi-h commented 9 years ago

I'm not sure whether this is more an AxonFramework issue than a quartz-mongodb one, but it will probably be easier to fix in this project :)

Axon uses fully qualified class names as keys in its job data maps when scheduling events. This leads to stack traces like the following:

java.lang.IllegalArgumentException: Document field names can't have a . in them. (Bad Key: 'org.axonframework.domain.EventMessage')
    at com.mongodb.DBCollection.validateKey(DBCollection.java:1910)
    at com.mongodb.DBCollection._checkKeys(DBCollection.java:1869)
    at com.mongodb.DBCollection._checkObject(DBCollection.java:1856)
    at com.mongodb.DBCollectionImpl.applyRulesForInsert(DBCollectionImpl.java:431)
    at com.mongodb.DBCollectionImpl.insertWithCommandProtocol(DBCollectionImpl.java:420)
    at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:188)
    at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:167)
    at com.mongodb.DBCollection.insert(DBCollection.java:93)
    at com.mongodb.DBCollection.insert(DBCollection.java:78)
    at com.mongodb.DBCollection.insert(DBCollection.java:120)
    at com.novemberain.quartz.mongodb.MongoDBJobStore.storeJobInMongo(MongoDBJobStore.java:1194)
    at com.novemberain.quartz.mongodb.MongoDBJobStore.storeJobAndTrigger(MongoDBJobStore.java:129)
    at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:886)
    at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249)
    at org.axonframework.eventhandling.scheduling.quartz.QuartzEventScheduler.schedule(QuartzEventScheduler.java:70)

I'm using 1.9.0 with AxonFramework 2.4.

michaelklishin commented 9 years ago
java.lang.IllegalArgumentException: Document field names can't have a . in them. (Bad Key: 'org.axonframework.domain.EventMessage')

Suggests a full class name is used as document key. I doubt it's an issue with either, just an edge case triggered by something in Axiom.

levi-h commented 9 years ago

The job store could escape the keys, for instance.

[Edit: this was a response to a question that was removed :)]

michaelklishin commented 9 years ago

No, we won't do any key encoding. You should be able to use an arbitrary key for your jobs.

levi-h commented 9 years ago

Perhaps I misunderstand what you're saying, but wouldn't escaping help me in using any character that I want (in this case a dot)?

michaelklishin commented 9 years ago

@levi-h jobs in Quartz can have any key you want.

Escaping sounds great in theory. Once you implement it, you discover that for some inputs it causes unintended changes (e.g. if you escape dots with _dot_ and then your input has an actual _dot_ sequence). So you can't correctly unescape.

So simply pick keys that do not violate MongoDB expectations.

levi-h commented 9 years ago

Sure, you'd have to escape the escape sequence as well. Or do something as described in http://docs.mongodb.org/manual/faq/developers/#faq-dollar-sign-escaping

Picking keys that are allowed by MongoDB is not as simple as it sounds for the framework user: it's Axon that uses the FQCN.