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):
http://forum.springsource.org/showth...ssion-question
I am loading an object from a collection that has these fields:
_id:"1234567"
_class:"hotelImages"
_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:
I'm unable to determine why MappingMongoConverter would not know how to deal with the PictureSet.Code:@Document(collection="hotelImages") @TypeAlias(value="hotelImages") public class HotelImages { @Id private String id; @Field("pictureSet") private PictureSet pictureSet; ...
The exception clearly indicates the mapper has found the correct class and annotations:
Code:2012-11-02 14:23:11,276:DEBUG:pool-6-thread-1:event.AbstractMongoEventListener onBeforeConvert(com.expedia.www.domain.hotelSummaryConsumer.documents.HotelImages@37e5dbb9) 2012-11-02 14:23:11,316:DEBUG:pool-6-thread-1:event.AbstractMongoEventListener onAfterSave(com.expedia.www.domain.hotelSummaryConsumer.documents.HotelImages@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 at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:475)
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?


Reply With Quote