Search in sources :

Example 1 with MessageToBinaryConverter

use of org.springframework.integration.mongodb.support.MessageToBinaryConverter in project spring-integration by spring-projects.

the class AbstractConfigurableMongoDbMessageStore method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    if (this.mongoTemplate == null) {
        if (this.mappingMongoConverter == null) {
            this.mappingMongoConverter = new MappingMongoConverter(new DefaultDbRefResolver(this.mongoDbFactory), new MongoMappingContext());
            this.mappingMongoConverter.setApplicationContext(this.applicationContext);
            List<Object> customConverters = new ArrayList<Object>();
            customConverters.add(new MessageToBinaryConverter());
            customConverters.add(new BinaryToMessageConverter());
            this.mappingMongoConverter.setCustomConversions(new MongoCustomConversions(customConverters));
            this.mappingMongoConverter.afterPropertiesSet();
        }
        this.mongoTemplate = new MongoTemplate(this.mongoDbFactory, this.mappingMongoConverter);
    }
    this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.applicationContext);
    IndexOperations indexOperations = this.mongoTemplate.indexOps(this.collectionName);
    indexOperations.ensureIndex(new Index(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC));
    indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC).on(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC).unique());
    indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC).on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.DESC).on(MessageDocumentFields.SEQUENCE, Sort.Direction.DESC));
}
Also used : MessageToBinaryConverter(org.springframework.integration.mongodb.support.MessageToBinaryConverter) IndexOperations(org.springframework.data.mongodb.core.index.IndexOperations) DefaultDbRefResolver(org.springframework.data.mongodb.core.convert.DefaultDbRefResolver) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MongoCustomConversions(org.springframework.data.mongodb.core.convert.MongoCustomConversions) ArrayList(java.util.ArrayList) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) Index(org.springframework.data.mongodb.core.index.Index) BinaryToMessageConverter(org.springframework.integration.mongodb.support.BinaryToMessageConverter) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate)

Aggregations

ArrayList (java.util.ArrayList)1 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)1 DefaultDbRefResolver (org.springframework.data.mongodb.core.convert.DefaultDbRefResolver)1 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)1 MongoCustomConversions (org.springframework.data.mongodb.core.convert.MongoCustomConversions)1 Index (org.springframework.data.mongodb.core.index.Index)1 IndexOperations (org.springframework.data.mongodb.core.index.IndexOperations)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1 BinaryToMessageConverter (org.springframework.integration.mongodb.support.BinaryToMessageConverter)1 MessageToBinaryConverter (org.springframework.integration.mongodb.support.MessageToBinaryConverter)1