Skip to content

Commit 481dec4

Browse files
committed
Fix MongoDb MessageDocument for latest Spring Data
1 parent 1043b00 commit 481dec4

File tree

1 file changed

+16
-2
lines changed
  • spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.data.annotation.AccessType;
2222
import org.springframework.data.annotation.Id;
23+
import org.springframework.data.annotation.PersistenceConstructor;
2324
import org.springframework.data.mongodb.core.mapping.Document;
2425
import org.springframework.messaging.Message;
2526
import org.springframework.util.Assert;
@@ -63,11 +64,24 @@ public class MessageDocument {
6364
private int sequence;
6465

6566
public MessageDocument(Message<?> message) {
67+
this(message, message.getHeaders().getId());
68+
}
69+
70+
/**
71+
* The special persistence constructor to populate a {@code final}
72+
* properties from the source MongoDB document.
73+
* @param message the {@link Message} this document is assigned.
74+
* @param messageId the id of the {@link Message} as a separate persistent property.
75+
* @since 5.1
76+
*/
77+
@PersistenceConstructor
78+
MessageDocument(Message<?> message, UUID messageId) {
6679
Assert.notNull(message, "'message' must not be null");
6780
this.message = message;
68-
this.messageId = message.getHeaders().getId();
81+
this.messageId = messageId;
6982
}
7083

84+
7185
public Message<?> getMessage() {
7286
return this.message;
7387
}

0 commit comments

Comments
 (0)