|
71 | 71 | import org.springframework.integration.support.MutableMessageBuilder;
|
72 | 72 | import org.springframework.integration.support.converter.WhiteListDeserializingConverter;
|
73 | 73 | import org.springframework.jmx.export.annotation.ManagedAttribute;
|
| 74 | +import org.springframework.lang.Nullable; |
74 | 75 | import org.springframework.messaging.Message;
|
75 | 76 | import org.springframework.messaging.MessageHeaders;
|
76 | 77 | import org.springframework.messaging.support.ErrorMessage;
|
@@ -104,21 +105,6 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
|
104 | 105 |
|
105 | 106 | private static final String DEFAULT_COLLECTION_NAME = "messages";
|
106 | 107 |
|
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 |
| - |
122 | 108 | private static final String GROUP_ID_KEY = "_groupId";
|
123 | 109 |
|
124 | 110 | private static final String GROUP_COMPLETE_KEY = "_group_complete";
|
@@ -160,7 +146,7 @@ public MongoDbMessageStore(MongoDbFactory mongoDbFactory) {
|
160 | 146 | * @param mongoDbFactory The mongodb factory.
|
161 | 147 | * @param collectionName The collection name.
|
162 | 148 | */
|
163 |
| - public MongoDbMessageStore(MongoDbFactory mongoDbFactory, String collectionName) { |
| 149 | + public MongoDbMessageStore(MongoDbFactory mongoDbFactory, @Nullable String collectionName) { |
164 | 150 | Assert.notNull(mongoDbFactory, "mongoDbFactory must not be null");
|
165 | 151 | this.converter = new MessageReadingMongoConverter(mongoDbFactory, new MongoMappingContext());
|
166 | 152 | this.template = new MongoTemplate(mongoDbFactory, this.converter);
|
@@ -198,15 +184,16 @@ public void afterPropertiesSet() {
|
198 | 184 |
|
199 | 185 | IndexOperations indexOperations = this.template.indexOps(this.collectionName);
|
200 | 186 |
|
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)); |
204 | 191 | }
|
205 | 192 |
|
206 | 193 | @Override
|
207 | 194 | public <T> Message<T> addMessage(Message<T> message) {
|
208 | 195 | Assert.notNull(message, "'message' must not be null");
|
209 |
| - this.addMessageDocument(new MessageWrapper(message)); |
| 196 | + addMessageDocument(new MessageWrapper(message)); |
210 | 197 | return message;
|
211 | 198 | }
|
212 | 199 |
|
@@ -454,15 +441,15 @@ private static Query whereMessageIdIsAndGroupIdIs(UUID id, Object groupId) {
|
454 | 441 | }
|
455 | 442 |
|
456 | 443 | 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)); |
458 | 445 | }
|
459 | 446 |
|
460 | 447 | private static Query whereGroupIdIs(Object groupId) {
|
461 | 448 | return new Query(Criteria.where(GROUP_ID_KEY).is(groupId));
|
462 | 449 | }
|
463 | 450 |
|
464 | 451 | 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)); |
466 | 453 | this.template.updateFirst(query, update, this.collectionName);
|
467 | 454 | }
|
468 | 455 |
|
|
0 commit comments