diff options
author | Karl Nilsson <kjnilsson@gmail.com> | 2021-11-26 16:33:59 +0000 |
---|---|---|
committer | Karl Nilsson <kjnilsson@gmail.com> | 2021-11-26 16:33:59 +0000 |
commit | 92ed64eb22b7de5699126ec4f2f6dd3e99ed8889 (patch) | |
tree | 61742099e909f7c282a5d61d16750815c9a339e0 | |
parent | 45f69f88296b92acbec209de8b8c02d4e7893667 (diff) | |
download | rabbitmq-server-git-92ed64eb22b7de5699126ec4f2f6dd3e99ed8889.tar.gz |
QQ: remove decoded properties before storing messages
We're also typically storing the encoded properties as well.
We only really need one. e.g. an enqueue command with a 2 byte payload
serialises to 290 bytes compared to 463. A nice saving.
-rw-r--r-- | deps/rabbit/src/rabbit_quorum_queue.erl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/deps/rabbit/src/rabbit_quorum_queue.erl b/deps/rabbit/src/rabbit_quorum_queue.erl index 62a08c5113..f101fd213b 100644 --- a/deps/rabbit/src/rabbit_quorum_queue.erl +++ b/deps/rabbit/src/rabbit_quorum_queue.erl @@ -839,7 +839,8 @@ deliver(true, Delivery, QState0) -> rabbit_fifo_client:enqueue(Delivery#delivery.msg_seq_no, Delivery#delivery.message, QState0). -deliver(QSs, #delivery{confirm = Confirm} = Delivery) -> +deliver(QSs, #delivery{confirm = Confirm} = Delivery0) -> + Delivery = clean_delivery(Delivery0), lists:foldl( fun({Q, stateless}, {Qs, Actions}) -> QRef = amqqueue:get_pid(Q), @@ -1623,3 +1624,21 @@ notify_decorators(QName, F, A) -> {error, not_found} -> ok end. + +%% remove any data that a quorum queue doesn't need +clean_delivery(#delivery{message = + #basic_message{content = Content0} = Msg} = Delivery) -> + Content = case Content0 of + #content{properties = none} -> + Content0; + #content{protocol = none} -> + Content0; + #content{properties = Props, + protocol = Proto} -> + Content0#content{properties = none, + properties_bin = Proto:encode_properties(Props)} + end, + + %% TODO: we could also consider clearing out he message id here + Delivery#delivery{message = Msg#basic_message{content = Content}}. + |