summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-06-10 16:12:04 +0100
committerSimon MacMullen <simon@rabbitmq.com>2013-06-10 16:12:04 +0100
commit8903e78550e21577492b43afb9ccecdf592f3d70 (patch)
tree6cb4a47bcbc0476637b553fb50ef5e5fb4dd7ddd
parent707afca8de5391de9be71251fc061870e23ed7fc (diff)
parentdcc666dae0f9ae6813bfae2a054de1dd13596cda (diff)
downloadrabbitmq-server-git-8903e78550e21577492b43afb9ccecdf592f3d70.tar.gz
Merge heads of stable
-rw-r--r--src/rabbit_amqqueue_process.erl21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 10813838a5..8441bd3c55 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -898,6 +898,7 @@ make_dead_letter_msg(Msg = #basic_message{content = Content,
end,
ReasonBin = list_to_binary(atom_to_list(Reason)),
TimeSec = rabbit_misc:now_ms() div 1000,
+ PerMsgTTL = per_msg_ttl_header(Content#content.properties),
HeadersFun2 =
fun (Headers) ->
%% The first routing key is the one specified in the
@@ -908,13 +909,25 @@ make_dead_letter_msg(Msg = #basic_message{content = Content,
{<<"queue">>, longstr, QName},
{<<"time">>, timestamp, TimeSec},
{<<"exchange">>, longstr, Exchange#resource.name},
- {<<"routing-keys">>, array, RKs1}],
+ {<<"routing-keys">>, array, RKs1}] ++ PerMsgTTL,
HeadersFun1(rabbit_basic:prepend_table_header(<<"x-death">>,
Info, Headers))
end,
- Content1 = rabbit_basic:map_headers(HeadersFun2, Content),
- Msg#basic_message{exchange_name = DLX, id = rabbit_guid:gen(),
- routing_keys = DeathRoutingKeys, content = Content1}.
+ Content1 = #content{properties = Props} =
+ rabbit_basic:map_headers(HeadersFun2, Content),
+ Content2 = Content1#content{properties =
+ Props#'P_basic'{expiration = undefined}},
+ Msg#basic_message{exchange_name = DLX,
+ id = rabbit_guid:gen(),
+ routing_keys = DeathRoutingKeys,
+ content = Content2}.
+
+per_msg_ttl_header(#'P_basic'{expiration = undefined}) ->
+ [];
+per_msg_ttl_header(#'P_basic'{expiration = Expiration}) ->
+ [{<<"original-expiration">>, longstr, Expiration}];
+per_msg_ttl_header(_) ->
+ [].
now_micros() -> timer:now_diff(now(), {0,0,0}).