Skip to content

Commit 14c6742

Browse files
committed
Fix compatibility with the latest SD MongoDB
https://build.spring.io/browse/INT-MASTER-1446/
1 parent d53433c commit 14c6742

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/MongoDbMessageStore.java

+9-22
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.springframework.integration.support.MutableMessageBuilder;
7272
import org.springframework.integration.support.converter.WhiteListDeserializingConverter;
7373
import org.springframework.jmx.export.annotation.ManagedAttribute;
74+
import org.springframework.lang.Nullable;
7475
import org.springframework.messaging.Message;
7576
import org.springframework.messaging.MessageHeaders;
7677
import org.springframework.messaging.support.ErrorMessage;
@@ -104,21 +105,6 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
104105

105106
private static final String DEFAULT_COLLECTION_NAME = "messages";
106107

107-
/**
108-
* The name of the message header that stores a flag to indicate that the message has been saved. This is an
109-
* optimization for the put method.
110-
* @deprecated since 5.0. This constant isn't used any more.
111-
*/
112-
@Deprecated
113-
public static final String SAVED_KEY = ConfigurableMongoDbMessageStore.class.getSimpleName() + ".SAVED";
114-
115-
/**
116-
* The name of the message header that stores a timestamp for the time the message was inserted.
117-
* @deprecated since 5.0. This constant isn't used any more.
118-
*/
119-
@Deprecated
120-
public static final String CREATED_DATE_KEY = ConfigurableMongoDbMessageStore.class.getSimpleName() + ".CREATED_DATE";
121-
122108
private static final String GROUP_ID_KEY = "_groupId";
123109

124110
private static final String GROUP_COMPLETE_KEY = "_group_complete";
@@ -160,7 +146,7 @@ public MongoDbMessageStore(MongoDbFactory mongoDbFactory) {
160146
* @param mongoDbFactory The mongodb factory.
161147
* @param collectionName The collection name.
162148
*/
163-
public MongoDbMessageStore(MongoDbFactory mongoDbFactory, String collectionName) {
149+
public MongoDbMessageStore(MongoDbFactory mongoDbFactory, @Nullable String collectionName) {
164150
Assert.notNull(mongoDbFactory, "mongoDbFactory must not be null");
165151
this.converter = new MessageReadingMongoConverter(mongoDbFactory, new MongoMappingContext());
166152
this.template = new MongoTemplate(mongoDbFactory, this.converter);
@@ -198,15 +184,16 @@ public void afterPropertiesSet() {
198184

199185
IndexOperations indexOperations = this.template.indexOps(this.collectionName);
200186

201-
indexOperations.ensureIndex(new Index(GROUP_ID_KEY, Sort.Direction.ASC)
202-
.on(GROUP_UPDATE_TIMESTAMP_KEY, Sort.Direction.DESC)
203-
.on(SEQUENCE, Sort.Direction.DESC));
187+
indexOperations.ensureIndex(
188+
new Index(GROUP_ID_KEY, Sort.Direction.ASC)
189+
.on(GROUP_UPDATE_TIMESTAMP_KEY, Sort.Direction.DESC)
190+
.on(SEQUENCE, Sort.Direction.DESC));
204191
}
205192

206193
@Override
207194
public <T> Message<T> addMessage(Message<T> message) {
208195
Assert.notNull(message, "'message' must not be null");
209-
this.addMessageDocument(new MessageWrapper(message));
196+
addMessageDocument(new MessageWrapper(message));
210197
return message;
211198
}
212199

@@ -454,15 +441,15 @@ private static Query whereMessageIdIsAndGroupIdIs(UUID id, Object groupId) {
454441
}
455442

456443
private static Query whereGroupIdOrder(Object groupId) {
457-
return whereGroupIdIs(groupId).with(new Sort(Sort.Direction.DESC, GROUP_UPDATE_TIMESTAMP_KEY, SEQUENCE));
444+
return whereGroupIdIs(groupId).with(Sort.by(Sort.Direction.DESC, GROUP_UPDATE_TIMESTAMP_KEY, SEQUENCE));
458445
}
459446

460447
private static Query whereGroupIdIs(Object groupId) {
461448
return new Query(Criteria.where(GROUP_ID_KEY).is(groupId));
462449
}
463450

464451
private void updateGroup(Object groupId, Update update) {
465-
Query query = whereGroupIdIs(groupId).with(new Sort(Sort.Direction.DESC, GROUP_UPDATE_TIMESTAMP_KEY, SEQUENCE));
452+
Query query = whereGroupIdIs(groupId).with(Sort.by(Sort.Direction.DESC, GROUP_UPDATE_TIMESTAMP_KEY, SEQUENCE));
466453
this.template.updateFirst(query, update, this.collectionName);
467454
}
468455

0 commit comments

Comments
 (0)