Announcement Announcement Module
No announcement yet.
Mongo: AbstractMongoEventListener to load a compressed object Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mongo: AbstractMongoEventListener to load a compressed object

    I'm trying to implement compression/decompression with an AbstractMongoEventListener and the "out of the box "MappingMongoConverter.
    See this post- (not getting any traction, so i'm trying again):

    I am loading an object from a collection that has these fields:
    _data: <Binary Data, an encoded BSON object that was created in my onAfterConvert() event>
    _compressed: true

    The _data value is an encoded BSON object, a serialized "HotelImages" class document that has mongo @Document and @Field annotations on it, and it's available to the MappingMongoCoverter.

    I extended the AbstractMongoEventListener (see code in previous post) and implemented onAfterConvert() to get the document, convert the object to the binary "_data" field and overwrite the BSON object to be persisted. The DB looks correct!

    The onAfterLoad() method decodes the binary "_data" field into a BSON document and overwrites the loaded BSON object with the value.

    The object contains a HotelImages object with a PictureSet attribute:
    public class HotelImages {
    	private String id;
    	private PictureSet pictureSet;
    I'm unable to determine why MappingMongoConverter would not know how to deal with the PictureSet.
    The exception clearly indicates the mapper has found the correct class and annotations:

    2012-11-02 14:23:11,276:DEBUG:pool-6-thread-1:event.AbstractMongoEventListener onBeforeConvert(co[email protected]37e5dbb9)
    2012-11-02 14:23:11,316:DEBUG:pool-6-thread-1:event.AbstractMongoEventListener onAfterSave(co[email protected]37e5dbb9, { "_id" : "1-1033" , "_class" : "hotelImages" , "_data" : <Binary Data> , "compressed" : true})
    2012-11-02 14:23:11,318:DEBUG:pool-6-thread-1:event.AbstractMongoEventListener onAfterLoad({ "_id" : "1-1033" , "_class" : "hotelImages" , "_data" : <Binary Data> , "compressed" : true})
    2012-11-02 14:23:11,323:INFO:pool-6-thread-1:repository.HotelImagesEntityCompressingEventListener Uncompressed object:{ "_id" : "1-1033" , "_class" : "hotelImages" , "pictureSet" : { "featured" : { "_id" : 464450 , 
    2012-11-02 14:23:26,763:ERROR:SimpleAsyncTaskExecutor-1:lcs.LCSDataImporterManager Task failed
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.bson.BasicBSONObject<?, ?> to type com.expedia.www.domain.hotelSummaryConsumer.documents.PictureSet

    In the onAfterLoad() method, I am clearing out the BSON object and overwriting it with the decoded data, and it looks identical to the loaded object if i don't use data compression. But the mapper is obviously unable to deal with what it's given: org.bson.BasicBSONObject<?, ?>.

    SIngle stepping through the converter is difficult to debug- still trying but maybe someone has some insight here?