Skip to content

Commit 2229324

Browse files
committed
Reuse timestamp in rabbit_message_interceptor
## What? `mc:init()` already sets mc annotation `rts` (received timestamp). This commit reuses this timestamp in `rabbit_message_interceptor`. ## Why? `os:system_time/1` can jump forward or backward between invocations. Using two different timestamps for the same meaning, the time the message was received by RabbitMQ, can be misleading. (cherry picked from commit f447986)
1 parent 9b04026 commit 2229324

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

deps/rabbit/src/rabbit_message_interceptor.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ intercept(Msg, set_header_routing_node, Overwrite) ->
2727
Node = atom_to_binary(node()),
2828
set_annotation(Msg, ?HEADER_ROUTING_NODE, Node, Overwrite);
2929
intercept(Msg0, set_header_timestamp, Overwrite) ->
30-
Millis = os:system_time(millisecond),
31-
Msg = set_annotation(Msg0, ?HEADER_TIMESTAMP, Millis, Overwrite),
32-
set_timestamp(Msg, Millis, Overwrite).
30+
Ts = mc:get_annotation(?ANN_RECEIVED_AT_TIMESTAMP, Msg0),
31+
Msg = set_annotation(Msg0, ?HEADER_TIMESTAMP, Ts, Overwrite),
32+
set_timestamp(Msg, Ts, Overwrite).
3333

3434
-spec set_annotation(mc:state(), mc:ann_key(), mc:ann_value(), boolean()) -> mc:state().
3535
set_annotation(Msg, Key, Value, Overwrite) ->

0 commit comments

Comments
 (0)