Skip to content

Commit 9e618da

Browse files
committed
提交warp
1 parent d4b652e commit 9e618da

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package io.arex.inst.mqtt.warp;
2+
3+
import org.springframework.messaging.MessageHeaders;
4+
5+
import java.util.Collections;
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
import java.util.UUID;
9+
10+
/**
11+
* @author : MentosL
12+
* @date : 2023/5/9 23:12
13+
*/
14+
public class MessageHeaderWarp extends MessageHeaders {
15+
16+
private final Map<String, Object> headers;
17+
private final UUID id;
18+
private final Long timestamp;
19+
20+
public MessageHeaderWarp(MessageHeaders messageHeaders) {
21+
super(null);
22+
this.headers = new HashMap<>();
23+
for (Map.Entry<String, Object> entry : messageHeaders.entrySet()) {
24+
this.headers.put(entry.getKey(), entry.getValue());
25+
}
26+
this.id = messageHeaders.getId();
27+
this.timestamp = messageHeaders.getTimestamp();
28+
}
29+
30+
public MessageHeaderWarp(Map<String, Object> headers) {
31+
super(headers);
32+
this.headers = headers;
33+
this.id = getIdGenerator().generateId();
34+
this.timestamp = System.currentTimeMillis();
35+
}
36+
37+
public MessageHeaderWarp(Map<String, Object> headers, UUID id, Long timestamp) {
38+
super(headers, id, timestamp);
39+
this.headers = headers;
40+
this.id = id;
41+
this.timestamp = timestamp;
42+
}
43+
44+
45+
46+
47+
48+
public Map<String, Object> getHeaders() {
49+
return Collections.unmodifiableMap(headers);
50+
}
51+
}

0 commit comments

Comments
 (0)