Example usage for org.springframework.integration.mongodb.store MessageDocumentFields LAST_MODIFIED_TIME

List of usage examples for org.springframework.integration.mongodb.store MessageDocumentFields LAST_MODIFIED_TIME

Introduction

In this page you can find the example usage for org.springframework.integration.mongodb.store MessageDocumentFields LAST_MODIFIED_TIME.

Prototype

String LAST_MODIFIED_TIME

To view the source code for org.springframework.integration.mongodb.store MessageDocumentFields LAST_MODIFIED_TIME.

Click Source Link

Usage

From source file:org.springframework.integration.mongodb.store.AbstractConfigurableMongoDbMessageStore.java

@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 CustomConversions(customConverters));
            this.mappingMongoConverter.afterPropertiesSet();
        }/*from   www . j av a 2  s.c  om*/
        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));
}