summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Klishin <michael@clojurewerkz.org>2019-01-02 02:36:56 +0300
committerMichael Klishin <michael@clojurewerkz.org>2019-01-02 02:36:56 +0300
commitb1b995ca9f7eb45c90cbfb31194c81af3e798321 (patch)
treebd613813049daaa1c34c37a466c81a88c6e7a5c6 /src
parent2cd21ee0e87cfd646b753cfbb8de32b50773bd68 (diff)
downloadrabbitmq-server-git-b1b995ca9f7eb45c90cbfb31194c81af3e798321.tar.gz
Rework message size limit test
* Use smaller messages for tests * No need to publish a message above the hard limit, use a helper (these are unit tests) * Wording
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_channel.erl23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 1579383f25..eeae247193 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -72,7 +72,7 @@
-export([get_vhost/1, get_user/1]).
%% For testing
-export([build_topic_variable_map/3]).
--export([list_queue_states/1]).
+-export([list_queue_states/1, get_max_message_size/0]).
%% Mgmt HTTP API refactor
-export([handle_method/5]).
@@ -443,12 +443,7 @@ init([Channel, ReaderPid, WriterPid, ConnPid, ConnName, Protocol, User, VHost,
_ ->
Limiter0
end,
- MaxMessageSize = case application:get_env(rabbit, max_message_size) of
- {ok, MS} when is_integer(MS) ->
- erlang:min(MS, ?MAX_MSG_SIZE);
- _ ->
- ?MAX_MSG_SIZE
- end,
+ MaxMessageSize = get_max_message_size(),
State = #ch{state = starting,
protocol = Protocol,
channel = Channel,
@@ -802,6 +797,16 @@ code_change(_OldVsn, State, _Extra) ->
format_message_queue(Opt, MQ) -> rabbit_misc:format_message_queue(Opt, MQ).
+-spec get_max_message_size() -> non_neg_integer().
+
+get_max_message_size() ->
+ case application:get_env(rabbit, max_message_size) of
+ {ok, MS} when is_integer(MS) ->
+ erlang:min(MS, ?MAX_MSG_SIZE);
+ _ ->
+ ?MAX_MSG_SIZE
+ end.
+
%%---------------------------------------------------------------------------
reply(Reply, NewState) -> {reply, Reply, next_state(NewState), hibernate}.
@@ -1000,9 +1005,9 @@ check_msg_size(Content, MaxMessageSize) ->
S when S > MaxMessageSize ->
ErrorMessage = case MaxMessageSize of
?MAX_MSG_SIZE ->
- "message size ~B larger than max size ~B";
+ "message size ~B is larger than max size ~B";
_ ->
- "message size ~B larger than configured max size ~B"
+ "message size ~B is larger than configured max size ~B"
end,
precondition_failed(ErrorMessage,
[Size, MaxMessageSize]);