Codebase list rabbitmq-server / 427dbd0
Merge tag 'upstream/3.5.4' Upstream version 3.5.4 James Page 8 years ago
352 changed file(s) with 1817 addition(s) and 1172 deletion(s). Raw diff Collapse all Expand all
9595 Authors and Copyright are as described below:
9696
9797 The Initial Developer of the Original Code is GoPivotal, Inc.
98 Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
98 Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
9999
100100
101101 MOZILLA PUBLIC LICENSE
547547 The Original Code is RabbitMQ.
548548
549549 The Initial Developer of the Original Code is GoPivotal, Inc.
550 Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.''
550 Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.''
551551
552552 [NOTE: The text of this Exhibit A may differ slightly from the text of
553553 the notices in the Source Code files of the Original Code. You should
2828 ifeq ($(shell python -c 'import simplejson' 2>/dev/null && echo yes),yes)
2929 PYTHON=python
3030 else
31 ifeq ($(shell python2.7 -c 'import json' 2>/dev/null && echo yes),yes)
32 PYTHON=python2.7
33 else
3134 ifeq ($(shell python2.6 -c 'import simplejson' 2>/dev/null && echo yes),yes)
3235 PYTHON=python2.6
3336 else
3639 else
3740 # Hmm. Missing simplejson?
3841 PYTHON=python
42 endif
3943 endif
4044 endif
4145 endif
225229 $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \
226230 RABBITMQ_NODE_ONLY=true \
227231 RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS)" \
228 ./scripts/rabbitmq-server
232 ./scripts/rabbitmq-server -detached
229233
230234 run-tests: all
231235 echo 'code:add_path("$(TEST_EBIN_DIR)").' | $(ERL_CALL)
241245 start-background-node: all
242246 -rm -f $(RABBITMQ_MNESIA_DIR).pid
243247 mkdir -p $(RABBITMQ_MNESIA_DIR)
244 nohup sh -c "$(MAKE) run-background-node > $(RABBITMQ_MNESIA_DIR)/startup_log 2> $(RABBITMQ_MNESIA_DIR)/startup_err" > /dev/null &
248 $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \
249 RABBITMQ_NODE_ONLY=true \
250 RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS)" \
251 ./scripts/rabbitmq-server \
252 > $(RABBITMQ_MNESIA_DIR)/startup_log \
253 2> $(RABBITMQ_MNESIA_DIR)/startup_err &
245254 ./scripts/rabbitmqctl -n $(RABBITMQ_NODENAME) wait $(RABBITMQ_MNESIA_DIR).pid kernel
246255
247256 start-rabbit-on-node: all
1010 ## The Original Code is RabbitMQ.
1111 ##
1212 ## The Initial Developer of the Original Code is GoPivotal, Inc.
13 ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 ##
1515
1616 from __future__ import nested_scopes
105105 %% The Original Code is RabbitMQ.
106106 %%
107107 %% The Initial Developer of the Original Code is GoPivotal, Inc.
108 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
108 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
109109 %%"""
110110
111111 def genErl(spec):
4040 <cmdsynopsis>
4141 <command>rabbitmqctl</command>
4242 <arg choice="opt">-n <replaceable>node</replaceable></arg>
43 <arg choice="opt">-t <replaceable>timeout</replaceable></arg>
4344 <arg choice="opt">-q</arg>
4445 <arg choice="req"><replaceable>command</replaceable></arg>
4546 <arg choice="opt" rep="repeat"><replaceable>command options</replaceable></arg>
9192 </para>
9293 </listitem>
9394 </varlistentry>
95 <varlistentry>
96 <term><cmdsynopsis><arg choice="opt">-t <replaceable>timeout</replaceable></arg></cmdsynopsis></term>
97 <listitem>
98 <para role="usage">
99 Operation timeout in seconds. Only applicable to "list" commands.
100 Default is "infinity".
101 </para>
102 </listitem>
103 </varlistentry>
94104 </variablelist>
95105 </refsect1>
96106
575585 <para>
576586 Instructs a synchronising mirrored queue to stop
577587 synchronising itself.
588 </para>
589 </listitem>
590 </varlistentry>
591 <varlistentry>
592 <term><cmdsynopsis><command>purge_queue</command> <arg choice="req">queue</arg></cmdsynopsis>
593 </term>
594 <listitem>
595 <variablelist>
596 <varlistentry>
597 <term>queue</term>
598 <listitem>
599 <para>
600 The name of the queue to purge.
601 </para>
602 </listitem>
603 </varlistentry>
604 </variablelist>
605 <para>
606 Purges a queue (removes all messages in it).
578607 </para>
579608 </listitem>
580609 </varlistentry>
00 {application, rabbit, %% -*- erlang -*-
11 [{description, "RabbitMQ"},
22 {id, "RabbitMQ"},
3 {vsn, "3.5.1"},
3 {vsn, "3.5.4"},
44 {modules, []},
55 {registered, [rabbit_amqqueue_sup,
66 rabbit_log,
7878 mnesia_lib, rpc, mnesia_tm, qlc, sofs, proplists, credit_flow,
7979 pmon, ssl_connection, tls_connection, ssl_record, tls_record,
8080 gen_fsm, ssl]},
81 {ssl_apps, [asn1, crypto, public_key, ssl]}
81 {ssl_apps, [asn1, crypto, public_key, ssl]},
82 %% see rabbitmq-server#114
83 {mirroring_flow_control, true}
8284 ]}]}.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -ifdef(use_specs).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% Passed around most places
103103
104104 %%----------------------------------------------------------------------------
105105
106 -define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2014 GoPivotal, Inc.").
106 -define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2015 Pivotal Software, Inc.").
107107 -define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/").
108108 -define(ERTS_MINIMUM, "5.6.3").
109109
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -define(NODE_OPT, "-n").
1717 -define(QUIET_OPT, "-q").
1818 -define(VHOST_OPT, "-p").
19 -define(TIMEOUT_OPT, "-t").
1920
2021 -define(VERBOSE_OPT, "-v").
2122 -define(MINIMAL_OPT, "-m").
3233 -define(NODE_DEF(Node), {?NODE_OPT, {option, Node}}).
3334 -define(QUIET_DEF, {?QUIET_OPT, flag}).
3435 -define(VHOST_DEF, {?VHOST_OPT, {option, "/"}}).
36 -define(TIMEOUT_DEF, {?TIMEOUT_OPT, {option, "infinity"}}).
3537
3638 -define(VERBOSE_DEF, {?VERBOSE_OPT, flag}).
3739 -define(MINIMAL_DEF, {?MINIMAL_OPT, flag}).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -include("rabbit.hrl").
5656
5757 VERSION:=0.0.0
5858
59 ifndef VERBOSE
60 QUIET:=@
61 endif
62
5963 #----------------------------------
6064
6165 all:
117121 #----------------------------------
118122
119123 $(REPOS):
120 retries=5; \
121 while ! git clone $(GIT_CORE_REPOBASE_FETCH)/$@$(GIT_CORE_SUFFIX_FETCH); do \
124 $(QUIET)retries=5; \
125 umbrella_branch="$$(git branch | awk '/^\* / { print $$2; }')"; \
126 if test "$$umbrella_branch" = "stable"; then \
127 branch_arg="-b $$umbrella_branch"; \
128 fi; \
129 while ! git clone $$branch_arg $(GIT_CORE_REPOBASE_FETCH)/$@$(GIT_CORE_SUFFIX_FETCH); do \
122130 retries=$$((retries - 1)); \
123131 if test "$$retries" = 0; then break; fi; \
124132 sleep 1; \
125133 done
126 test -d $@
127 global_user_name="$$(git config --global user.name)"; \
134 $(QUIET)test -d $@
135 $(QUIET)global_user_name="$$(git config --global user.name)"; \
128136 global_user_email="$$(git config --global user.email)"; \
129137 user_name="$$(git config user.name)"; \
130138 user_email="$$(git config user.email)"; \
159167 sync-gitremote:
160168 @for repo in $(REPOS); do \
161169 cd $$repo && \
162 git remote set-url --fetch origin $(GIT_CORE_REPOBASE_FETCH)/$$repo$(GIT_CORE_SUFFIX_FETCH) && \
170 git remote set-url origin $(GIT_CORE_REPOBASE_FETCH)/$$repo$(GIT_CORE_SUFFIX_FETCH) && \
163171 git remote set-url --push origin $(GIT_CORE_REPOBASE_PUSH)/$$repo$(GIT_CORE_SUFFIX_PUSH) && \
164172 cd ..; done
165173
199207 pull: $(foreach DIR,. $(REPOS),$(DIR)+pull)
200208
201209 $(eval $(call repo_targets,. $(REPOS),pull,| %,\
202 (cd % && git pull --ff-only)))
210 (cd % && git fetch -p && \
211 (! git symbolic-ref -q HEAD || git pull --ff-only))))
203212
204213 .PHONY: update
205214 update: pull
209218
210219 $(eval $(call repo_targets,. $(REPOS),named_update,| %,\
211220 (cd % && git fetch -p && git checkout $(BRANCH) && \
212 (test "$$$$(git branch | grep '^*')" = "* (detached from $(BRANCH))" || \
213 git pull --ff-only))))
221 (! git symbolic-ref -q HEAD || git pull --ff-only))))
214222
215223 .PHONY: tag
216224 tag: $(foreach DIR,. $(REPOS),$(DIR)+tag)
309309 set --offline $$$$(RABBITMQ_PLUGINS_DIR=$(TEST_TMPDIR)/plugins \
310310 RABBITMQ_ENABLED_PLUGINS_FILE=$(TEST_TMPDIR)/enabled_plugins \
311311 $(UMBRELLA_BASE_DIR)/rabbitmq-server/scripts/rabbitmq-plugins list -m | tr '\n' ' ')
312 RABBITMQ_PLUGINS_DIR=$(TEST_TMPDIR)/plugins \
312 MAKE="$(MAKE)" \
313 RABBITMQ_PLUGINS_DIR=$(TEST_TMPDIR)/plugins \
313314 RABBITMQ_ENABLED_PLUGINS_FILE=$(TEST_TMPDIR)/enabled_plugins \
314315 RABBITMQ_LOG_BASE=$(TEST_TMPDIR)/log \
315316 RABBITMQ_MNESIA_BASE=$(TEST_TMPDIR)/$(NODENAME) \
338339 | $(ERL_CALL) $(ERL_CALL_OPTS) \
339340 | tee -a $(TEST_TMPDIR)/rabbit-test-output \
340341 | egrep "{ok, (ok|passed)}" >/dev/null &&) \
341 $(foreach SCRIPT,$(WITH_BROKER_TEST_SCRIPTS),$(SCRIPT) &&) : ; \
342 MAKE="$(MAKE)" RABBITMQ_NODENAME="$(NODENAME)" \
343 $(foreach SCRIPT,$(WITH_BROKER_TEST_SCRIPTS),$(SCRIPT) &&) : ; \
342344 then \
343345 touch $(TEST_TMPDIR)/.passed ; \
344 echo "\nPASSED\n" ; \
346 printf "\nPASSED\n" ; \
345347 else \
346348 cat $(TEST_TMPDIR)/rabbit-test-output ; \
347 echo "\n\nFAILED\n" ; \
349 printf "\n\nFAILED\n" ; \
348350 fi
349351 sleep 1
350352 echo "rabbit_misc:report_cover(), init:stop()." | $(ERL_CALL) $(ERL_CALL_OPTS)
0 CLIENT_DIR=swiftmq_9_2_5_client
1 CLIENT_PKG=$(CLIENT_DIR).zip
0 CLIENT_DIR=swiftmq_9_7_1_client
1 CLIENT_PKG=$(CLIENT_DIR).tar.gz
22
33 .PHONY: test
44
77
88 build/lib: $(CLIENT_PKG)
99 mkdir -p build/tmp
10 unzip -d build/tmp $(CLIENT_PKG)
10 tar -zx -f $(CLIENT_PKG) -C build/tmp
1111 mkdir -p build/lib
1212 mv build/tmp/$(CLIENT_DIR)/jars/*.jar build/lib
1313 rm -rf build/tmp
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_ldap).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_ldap_app).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_ldap_util).
1010 %% The Original Code is RabbitMQ
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_ldap_test).
1010 %% The Original Code is RabbitMQ
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_ldap_unit_test).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_mechanism_ssl_app).
1010 # The Original Code is RabbitMQ.
1111 #
1212 # The Initial Developer of the Original Code is GoPivotal, Inc.
13 # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 #
1515
1616 VERSION=0.0.0
1010 # The Original Code is RabbitMQ.
1111 #
1212 # The Initial Developer of the Original Code is GoPivotal, Inc.
13 # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 #
1515
1616 VERSION=%%VSN%%
1010 # The Original Code is RabbitMQ.
1111 #
1212 # The Initial Developer of the Original Code is GoPivotal, Inc.
13 # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 #
1515
1616 # The client library can either be built from source control or by downloading
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -ifndef(AMQP_CLIENT_HRL).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -include("amqp_client.hrl").
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -include("amqp_client.hrl").
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -define(QUEUE_PREFIX, "/queue").
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @type close_reason(Type) = {shutdown, amqp_reason(Type)}.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @type close_reason(Type) = {shutdown, amqp_reason(Type)}.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
7373 {ok, State};
7474 handle_message(closing_timeout, State = #state{closing_reason = Reason}) ->
7575 {stop, {closing_timeout, Reason}, State};
76 handle_message({'DOWN', _MRef, process, _ConnSup, shutdown}, State) ->
77 {stop, {shutdown, node_down}, State};
7678 handle_message({'DOWN', _MRef, process, _ConnSup, Reason}, State) ->
7779 {stop, {remote_node_down, Reason}, State};
7880 handle_message(Msg, State) ->
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @doc This module is an implementation of the amqp_gen_consumer
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @doc A behaviour module for implementing consumers for
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
303303 {<<"version">>, longstr, list_to_binary(Vsn)},
304304 {<<"platform">>, longstr, <<"Erlang">>},
305305 {<<"copyright">>, longstr,
306 <<"Copyright (c) 2007-2014 GoPivotal, Inc.">>},
306 <<"Copyright (c) 2007-2015 Pivotal Software, Inc.">>},
307307 {<<"information">>, longstr,
308308 <<"Licensed under the MPL. "
309309 "See http://www.rabbitmq.com/">>},
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @doc This module allows the simple execution of an asynchronous RPC over
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @doc This is a utility module that is used to expose an arbitrary function
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @doc This module is an implementation of the amqp_gen_consumer
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% @private
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(amqp_uri).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2013-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2013-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_routing_util).
1010 # The Original Code is RabbitMQ.
1111 #
1212 # The Initial Developer of the Original Code is GoPivotal, Inc.
13 # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 #
1515
1616 TEST_SOURCES=$(wildcard *.erl)
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(amqp_client_SUITE).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(amqp_dbg).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(negative_test_util).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(test_util).
1010 # The Original Code is RabbitMQ.
1111 #
1212 # The Initial Developer of the Original Code is GoPivotal, Inc.
13 # Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 # Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 #
1515
1616 IS_SUCCESS:=egrep "(All .+ tests (successful|passed).|Test passed.)"
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -record(upstream, {uris,
2424 trust_user_id,
2525 ack_mode,
2626 ha_policy,
27 name}).
27 name,
28 bind_nowait}).
2829
2930 -record(upstream_params,
3031 {uri,
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_app).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_db).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_event).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% TODO rename this
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_exchange_link).
273273
274274 bind_cmd(Type, #binding{key = Key, args = Args},
275275 State = #state{internal_exchange = IntXNameBin,
276 upstream_params = UpstreamParams}) ->
276 upstream_params = UpstreamParams,
277 upstream = Upstream}) ->
277278 #upstream_params{x_or_q = X} = UpstreamParams,
279 #upstream{bind_nowait = Nowait} = Upstream,
278280 case update_binding(Args, State) of
279281 ignore -> ignore;
280 NewArgs -> bind_cmd0(Type, name(X), IntXNameBin, Key, NewArgs)
282 NewArgs -> bind_cmd0(Type, name(X), IntXNameBin, Key, NewArgs, Nowait)
281283 end.
282284
283 bind_cmd0(bind, Source, Destination, RoutingKey, Arguments) ->
285 bind_cmd0(bind, Source, Destination, RoutingKey, Arguments, Nowait) ->
284286 #'exchange.bind'{source = Source,
285287 destination = Destination,
286288 routing_key = RoutingKey,
287 arguments = Arguments};
288
289 bind_cmd0(unbind, Source, Destination, RoutingKey, Arguments) ->
289 arguments = Arguments,
290 nowait = Nowait};
291
292 bind_cmd0(unbind, Source, Destination, RoutingKey, Arguments, Nowait) ->
290293 #'exchange.unbind'{source = Source,
291294 destination = Destination,
292295 routing_key = RoutingKey,
293 arguments = Arguments}.
296 arguments = Arguments,
297 nowait = Nowait}.
294298
295299 %% This function adds information about the current node to the
296300 %% binding arguments, or returns 'ignore' if it determines the binding
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_exchange_link_sup_sup).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_link_sup).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_link_util).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_parameters).
9090 {<<"trust-user-id">>, fun rabbit_parameter_validation:boolean/2, optional},
9191 {<<"ack-mode">>, rabbit_parameter_validation:enum(
9292 ['no-ack', 'on-publish', 'on-confirm']), optional},
93 {<<"ha-policy">>, fun rabbit_parameter_validation:binary/2, optional}].
93 {<<"ha-policy">>, fun rabbit_parameter_validation:binary/2, optional},
94 {<<"bind-nowait">>, fun rabbit_parameter_validation:boolean/2, optional}].
9495
9596 validate_uri(Name, Term) when is_binary(Term) ->
9697 case rabbit_parameter_validation:binary(Name, Term) of
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_queue).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_queue_link).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_queue_link_sup_sup).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_status).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_sup).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_upstream).
130130 binary_to_list(
131131 bget('ack-mode', US, U, <<"on-confirm">>))),
132132 ha_policy = bget('ha-policy', US, U, none),
133 name = Name}.
133 name = Name,
134 bind_nowait = bget('bind-nowait', US, U, false)}.
134135
135136 %%----------------------------------------------------------------------------
136137
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_upstream_exchange).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_util).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_exchange_test).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_queue_test).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_test_util).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_unit_test).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_federation_mgmt).
446446 The Original Code is RabbitMQ Management Plugin.
447447
448448 The Initial Developer of the Original Code is GoPivotal, Inc.
449 Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.''
449 Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.''
450450
451451 [NOTE: The text of this Exhibit A may differ slightly from the text of
452452 the notices in the Source Code files of the Original Code. You should
1212 # The Original Code is RabbitMQ Management Plugin.
1313 #
1414 # The Initial Developer of the Original Code is GoPivotal, Inc.
15 # Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
15 # Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1616
1717 import sys
1818 if sys.version_info[0] < 2 or (sys.version_info[0] == 2 and sys.version_info[1] < 6):
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -record(context, {user, password = none}).
1111 %>
1212 <p class="status-error">
1313 Network partition detected<br/><br/>
14 Mnesia reports that this RabbitMQ cluster has experienced a network partition. This is a dangerous situation. RabbitMQ clusters should not be installed on networks which can experience partitions.
14 Mnesia reports that this RabbitMQ cluster has experienced a
15 network partition. There is a risk of losing data. Please read
16 <a href="http://www.rabbitmq.com/partitions.html">RabbitMQ
17 documentation about network partitions and the possible solutions</a>.
1518 </p>
1619 <p>
1720 The nature of the partition is as follows:
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_app).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_db).
743743 end.
744744
745745 append_sample(Key, Val, NewMS, OldStats, Id, Agg, State) when is_number(Val) ->
746 record_sample(
747 Id, {Key, Val - pget(Key, OldStats, 0), NewMS, State}, Agg, State);
748
746 OldVal = case pget(Key, OldStats, 0) of
747 N when is_number(N) -> N;
748 _ -> 0
749 end,
750 record_sample(Id, {Key, Val - OldVal, NewMS, State}, Agg, State),
751 ok;
749752 append_sample(_Key, _Value, _NewMS, _OldStats, _Id, _Agg, _State) ->
750753 ok.
751754
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_dispatcher).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_extension).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_format).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_load_definitions).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2013 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% When management extensions are enabled and/or disabled at runtime, the
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_sup).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_sup_sup).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_util).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_aliveness_test).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_binding).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_bindings).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_channel).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_channels).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_cluster_name).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_connection).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_connection_channels).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_connections).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414
1515 -module(rabbit_mgmt_wm_consumers).
1616
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_definitions).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_exchange).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_exchange_publish).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_exchanges).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_extensions).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_node).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_nodes).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_overview).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_parameter).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_parameters).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_permission).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_permissions).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_permissions_user).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_permissions_vhost).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_policies).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_policy).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_queue).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_queue_get).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_queue_purge).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_queues).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_user).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_users).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_vhost).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_vhosts).
1010 %% The Original Code is RabbitMQ Management Plugin.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_wm_whoami).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_test_db).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_test_http).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_test_unit).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_agent_app).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_agent_sup).
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_db_handler).
4141 gc() ->
4242 erlang:garbage_collect(whereis(rabbit_event)).
4343
44 %% some people have reasons to only run with the agent enabled:
45 %% make it possible for them to configure key management app
46 %% settings such as rates_mode.
47 get_management_env(Key) ->
48 rabbit_misc:get_env(
49 rabbitmq_management, Key,
50 rabbit_misc:get_env(rabbitmq_management_agent, Key, undefined)).
51
4452 rates_mode() ->
45 case application:get_env(rabbitmq_management, rates_mode) of
46 {ok, Mode} -> Mode;
47 _ -> basic
53 case get_management_env(rates_mode) of
54 undefined -> basic;
55 Mode -> Mode
56 end.
57
58 handle_force_fine_statistics() ->
59 case get_management_env(force_fine_statistics) of
60 undefined ->
61 ok;
62 X ->
63 rabbit_log:warning(
64 "force_fine_statistics set to ~p; ignored.~n"
65 "Replaced by {rates_mode, none} in the rabbitmq_management "
66 "application.~n", [X])
4867 end.
4968
5069 %%----------------------------------------------------------------------------
5170
5271 ensure_statistics_enabled() ->
5372 ForceStats = rates_mode() =/= none,
54 case application:get_env(rabbitmq_management_agent,
55 force_fine_statistics) of
56 {ok, X} ->
57 rabbit_log:warning(
58 "force_fine_statistics set to ~p; ignored.~n"
59 "Replaced by {rates_mode, none} in the rabbitmq_management "
60 "application.~n", [X]);
61 undefined ->
62 ok
63 end,
73 handle_force_fine_statistics(),
6474 {ok, StatsLevel} = application:get_env(rabbit, collect_statistics),
75 rabbit_log:info("Management plugin: using rates mode '~p'~n", [rates_mode()]),
6576 case {ForceStats, StatsLevel} of
6677 {true, fine} ->
6778 ok;
1010 %% The Original Code is RabbitMQ Management Console.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mgmt_external_stats).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -define(CLIENT_ID_MAXLEN, 23).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -define(PROTOCOL_NAMES, [{3, "MQIsdp"}, {4, "MQTT"}]).
99 rm -rf $(PACKAGE_DIR)/test/certs
1010 mkdir $(PACKAGE_DIR)/test/certs
1111 mkdir -p $(PACKAGE_DIR)/test/ebin
12 sed -e "s|%%CERTS_DIR%%|$(abspath $(PACKAGE_DIR))/test/certs|g" < $(PACKAGE_DIR)/test/src/test.config > $(PACKAGE_DIR)/test/ebin/test.config
13 make -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=bunnychow DIR=$(abspath $(PACKAGE_DIR))/test/certs
12 sed -E -e "s|%%CERTS_DIR%%|$(abspath $(PACKAGE_DIR))/test/certs|g" < $(PACKAGE_DIR)/test/src/test.config > $(PACKAGE_DIR)/test/ebin/test.config
13 $(MAKE) -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=bunnychow DIR=$(abspath $(PACKAGE_DIR))/test/certs
1414
1515 $(PACKAGE_DIR)+clean::
1616 rm -rf $(PACKAGE_DIR)/test/certs
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_collector).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_connection_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_frame).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_processor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_reader).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_sup).
3131 = case SslListeners0 of
3232 [] -> {none, []};
3333 _ -> {rabbit_networking:ensure_ssl(),
34 case rabbit_networking:poodle_check('STOMP') of
34 case rabbit_networking:poodle_check('MQTT') of
3535 ok -> SslListeners0;
3636 danger -> []
3737 end}
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mqtt_util).
3838
3939 .PHONY: build_java_amqp
4040 build_java_amqp: $(CHECKOUT_DIR)
41 make -C $(JAVA_AMQP_DIR) jar
42
41 $(MAKE) -C $(JAVA_AMQP_DIR) jar
1010 // The Original Code is RabbitMQ.
1111 //
1212 // The Initial Developer of the Original Code is GoPivotal, Inc.
13 // Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 // Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 //
1515
1616 package com.rabbitmq.mqtt.test;
3939 import java.util.ArrayList;
4040 import java.util.Arrays;
4141 import java.util.List;
42 import java.util.concurrent.TimeoutException;
4243
4344 /***
4445 * MQTT v3.1 tests
109110 } catch (Exception _) {}
110111 }
111112
112 private void setUpAmqp() throws IOException {
113 private void setUpAmqp() throws IOException, TimeoutException {
113114 connectionFactory = new ConnectionFactory();
114115 connectionFactory.setHost(host);
115116 conn = connectionFactory.newConnection();
376377 }
377378 }
378379
379 public void testInteropM2A() throws MqttException, IOException, InterruptedException {
380 public void testInteropM2A() throws MqttException, IOException, InterruptedException, TimeoutException {
380381 setUpAmqp();
381382 String queue = ch.queueDeclare().getQueue();
382383 ch.queueBind(queue, "amq.topic", topic);
392393 tearDownAmqp();
393394 }
394395
395 public void testInteropA2M() throws MqttException, IOException, InterruptedException {
396 public void testInteropA2M() throws MqttException, IOException, InterruptedException, TimeoutException {
396397 client.connect(conOpt);
397398 client.setCallback(this);
398399 client.subscribe(topic, 1);
1010 // The Original Code is RabbitMQ.
1111 //
1212 // The Initial Developer of the Original Code is GoPivotal, Inc.
13 // Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 // Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 //
1515
1616 package com.rabbitmq.mqtt.test.tls;
00 #!/bin/sh
1 make -C `dirname $0` build_java_amqp
2 make -C `dirname $0` test
1 $MAKE -C `dirname $0` build_java_amqp
2 $MAKE -C `dirname $0` test
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -record(endpoint,
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_config).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_dyn_worker_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_dyn_worker_sup_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_parameters).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_status).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_util).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_worker).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_worker_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_test).
1010 %% The Original Code is RabbitMQ
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_test_all).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_shovel_test_dyn).
44
55 rabbitmq-plugins enable rabbitmq_stomp
66
7 Binaries for previous versions of the STOMP adapter can be obtained
8 from
9 <http://www.rabbitmq.com/plugins.html#rabbitmq-stomp>.
7 ## Supported STOMP Versions
108
11 Full usage instructions can be found at
12 <http://www.rabbitmq.com/stomp.html>.
9 1.0 through 1.2.
10
11 ## Documentation
12
13 [RabbitMQ STOMP plugin documentation](http://www.rabbitmq.com/stomp.html).
0 UPSTREAM_HG=https://stomppy.googlecode.com/hg/
1 REVISION=16a4000624a7
0 UPSTREAM_GIT=https://github.com/jasonrbriggs/stomp.py.git
1 REVISION=v4.0.16
22
33 LIB_DIR=stomppy
4 CHECKOUT_DIR=stomppy-hg
4 CHECKOUT_DIR=stomppy-git
55
66 TARGETS=$(LIB_DIR)
77
1313 distclean: clean
1414 rm -rf $(CHECKOUT_DIR)
1515
16 $(LIB_DIR) : $(CHECKOUT_DIR) rabbit.patch
16 $(LIB_DIR) : $(CHECKOUT_DIR)
1717 rm -rf $@
1818 cp -R $< $@
19 cd $@ && patch -p1 < ../rabbit.patch
2019
2120 $(CHECKOUT_DIR):
22 hg clone $(UPSTREAM_HG) $@
23 (cd $@ && hg up $(REVISION)) || rm -rf $@
21 git clone $(UPSTREAM_GIT) $@
22 (cd $@ && git checkout $(REVISION)) || rm -rf $@
2423
2524 echo-revision:
2625 @echo $(REVISION)
+0
-116
plugins-src/rabbitmq-stomp/deps/stomppy/rabbit.patch less more
0 diff -r 16a4000624a7 stomp/connect.py
1 --- a/stomp/connect.py Sun May 02 18:15:34 2010 +0100
2 +++ b/stomp/connect.py Mon Oct 20 19:35:44 2014 +0100
3 @@ -88,7 +88,10 @@
4 ssl_key_file = None,
5 ssl_cert_file = None,
6 ssl_ca_certs = None,
7 - ssl_cert_validator = None):
8 + ssl_cert_validator = None,
9 + version = None,
10 + heartbeat = None,
11 + virtual_host = None):
12 """
13 Initialize and start this connection.
14
15 @@ -159,6 +162,16 @@
16
17 where OK is a boolean, and cert is a certificate structure
18 as returned by ssl.SSLSocket.getpeercert()
19 +
20 + \param version
21 + (optional) stomp version header to send (comma separated)
22 +
23 + \param heartbeat
24 + (optional) heartbeat header to send (STOMP 1.1)
25 +
26 + \param virtual_host
27 + (optional) virtual_host header to send (STOMP 1.1)
28 +
29 """
30
31 sorted_host_and_ports = []
32 @@ -205,6 +218,15 @@
33 self.__connect_headers['login'] = user
34 self.__connect_headers['passcode'] = passcode
35
36 + if version is not None:
37 + self.__connect_headers['accept-version'] = version
38 +
39 + if heartbeat is not None:
40 + self.__connect_headers['heart-beat'] = heartbeat
41 +
42 + if virtual_host is not None:
43 + self.__connect_headers['host'] = virtual_host
44 +
45 self.__socket = None
46 self.__socket_semaphore = threading.BoundedSemaphore(1)
47 self.__current_host_and_port = None
48 @@ -383,6 +405,10 @@
49 """
50 self.__send_frame_helper('DISCONNECT', '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
51 self.__running = False
52 + self.close_socket()
53 + self.__current_host_and_port = None
54 +
55 + def close_socket(self):
56 if self.__socket is not None:
57 if self.__ssl:
58 #
59 @@ -390,20 +416,23 @@
60 #
61 try:
62 self.__socket = self.__socket.unwrap()
63 - except Exception:
64 + except Exception as e:
65 #
66 # unwrap seems flaky on Win with the backported ssl mod, so catch any exception and log it
67 #
68 - _, e, _ = sys.exc_info()
69 - log.warn(e)
70 + log.warning("socket unwrap() threw exception: %s" % e)
71 elif hasattr(socket, 'SHUT_RDWR'):
72 - self.__socket.shutdown(socket.SHUT_RDWR)
73 + try:
74 + self.__socket.shutdown(socket.SHUT_RDWR)
75 + except Exception as e:
76 + log.warning("socket shutdown() threw exception: %s" % e)
77 #
78 - # split this into a separate check, because sometimes the socket is nulled between shutdown and this call
79 + # caution, because sometimes the socket is nulled between shutdown and this call
80 #
81 - if self.__socket is not None:
82 + try:
83 self.__socket.close()
84 - self.__current_host_and_port = None
85 + except Exception as e:
86 + log.warning("socket close() threw exception: %s" % e)
87
88 def __convert_dict(self, payload):
89 """
90 @@ -449,6 +478,9 @@
91 raise KeyError("Command %s requires header %r" % (command, required_header_key))
92 self.__send_frame(command, headers, payload)
93
94 + def send_frame(self, command, headers={}, payload=''):
95 + self.__send_frame(command, headers, payload)
96 +
97 def __send_frame(self, command, headers={}, payload=''):
98 """
99 Send a STOMP frame.
100 @@ -638,7 +670,7 @@
101 cert_validation = ssl.CERT_NONE
102 self.__socket = ssl.wrap_socket(self.__socket, keyfile = self.__ssl_key_file,
103 certfile = self.__ssl_cert_file, cert_reqs = cert_validation,
104 - ca_certs=self.__ssl_ca_certs, ssl_version = ssl.PROTOCOL_SSLv3)
105 + ca_certs=self.__ssl_ca_certs, ssl_version = ssl.PROTOCOL_TLSv1)
106 self.__socket.settimeout(None)
107 if self.blocking is not None:
108 self.__socket.setblocking(self.blocking)
109 @@ -680,4 +712,4 @@
110 sleep_exp += 1
111
112 if not self.__socket:
113 - raise exception.ReconnectFailedException
114 \ No newline at end of file
115 + raise exception.ReconnectFailedException
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -record(stomp_configuration, {default_login,
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -record(stomp_frame, {command, headers, body_iolist}).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -define(HEADER_ACCEPT_VERSION, "accept-version").
00 RELEASABLE:=true
11 DEPS:=rabbitmq-server rabbitmq-erlang-client rabbitmq-test
2 STANDALONE_TEST_COMMANDS:=eunit:test([rabbit_stomp_test_util,rabbit_stomp_test_frame],[verbose])
2 #STANDALONE_TEST_COMMANDS:=eunit:test([rabbit_stomp_test_util,rabbit_stomp_test_frame],[verbose])
33 WITH_BROKER_TEST_SCRIPTS:=$(PACKAGE_DIR)/test/src/test.py $(PACKAGE_DIR)/test/src/test_connect_options.py $(PACKAGE_DIR)/test/src/test_ssl.py
4 WITH_BROKER_TEST_COMMANDS:=rabbit_stomp_test:all_tests() rabbit_stomp_amqqueue_test:all_tests()
4 #WITH_BROKER_TEST_COMMANDS:=rabbit_stomp_test:all_tests() rabbit_stomp_amqqueue_test:all_tests()
55 WITH_BROKER_TEST_CONFIG:=$(PACKAGE_DIR)/test/ebin/test
66
77 define package_rules
1111 mkdir $(PACKAGE_DIR)/test/certs
1212 mkdir -p $(PACKAGE_DIR)/test/ebin
1313 sed -e "s|%%CERTS_DIR%%|$(abspath $(PACKAGE_DIR))/test/certs|g" < $(PACKAGE_DIR)/test/src/test.config > $(PACKAGE_DIR)/test/ebin/test.config
14 make -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=test DIR=$(abspath $(PACKAGE_DIR))/test/certs
15 make -C $(PACKAGE_DIR)/deps/stomppy
14 $(MAKE) -C $(PACKAGE_DIR)/../rabbitmq-test/certs all PASSWORD=test DIR=$(abspath $(PACKAGE_DIR))/test/certs
15 $(MAKE) -C $(PACKAGE_DIR)/deps/stomppy
1616
1717 $(PACKAGE_DIR)+clean::
1818 rm -rf $(PACKAGE_DIR)/test/certs
1919
2020 $(PACKAGE_DIR)+clean-with-deps::
21 make -C $(PACKAGE_DIR)/deps/stomppy distclean
21 $(MAKE) -C $(PACKAGE_DIR)/deps/stomppy distclean
2222
2323 endef
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_client_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% stomp_frame implements the STOMP framing protocol "version 1.0", as
150150 false -> [{Name, Value} | Headers]
151151 end.
152152
153 parse_body(Content, Frame) ->
154 parse_body(Content, Frame, [],
155 integer_header(Frame, ?HEADER_CONTENT_LENGTH, unknown)).
153 parse_body(Content, Frame = #stomp_frame{command = Command}) ->
154 case Command of
155 "SEND" -> parse_body(Content, Frame, [], integer_header(Frame, ?HEADER_CONTENT_LENGTH, unknown));
156 _ -> parse_body(Content, Frame, [], unknown)
157 end.
156158
157159 parse_body(Content, Frame, Chunks, unknown) ->
158160 parse_body2(Content, Frame, Chunks, case firstnull(Content) of
230232 Len > 0 -> [?HEADER_CONTENT_LENGTH ++ ":", integer_to_list(Len), ?LF];
231233 true -> []
232234 end,
233 ?LF, BodyFragments, 0].
235 ?LF, BodyFragments, 0, ?LF].
234236
235237 serialize_header({K, V}) when is_integer(V) -> hdr(escape(K), integer_to_list(V));
236238 serialize_header({K, V}) when is_list(V) -> hdr(escape(K), escape(V)).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_processor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_reader).
7373 catch _:Ex ->
7474 log_network_error(ConnStr, Ex),
7575 rabbit_net:fast_close(Sock),
76 rabbit_stomp_processor:flush_and_die(ProcessorPid),
7677 exit(normal)
7778 end,
7879 done;
7980 {error, enotconn} ->
8081 rabbit_net:fast_close(Sock0),
82 rabbit_stomp_processor:flush_and_die(ProcessorPid),
8183 exit(normal);
8284 {error, Reason} ->
8385 log_network_error(ConnStr, Reason),
8486 rabbit_net:fast_close(Sock0),
87 rabbit_stomp_processor:flush_and_die(ProcessorPid),
8588 exit(normal)
8689 end
8790 end
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_util).
55 class TestAck(base.BaseTest):
66
77 def test_ack_client(self):
8 d = "/queue/ack-test"
8 destination = "/queue/ack-test"
99
1010 # subscribe and send message
1111 self.listener.reset(2) ## expecting 2 messages
12 self.conn.subscribe(destination=d, ack='client',
12 self.subscribe_dest(self.conn, destination, None,
13 ack='client',
1314 headers={'prefetch-count': '10'})
14 self.conn.send("test1", destination=d)
15 self.conn.send("test2", destination=d)
15 self.conn.send(destination, "test1")
16 self.conn.send(destination, "test2")
1617 self.assertTrue(self.listener.await(4), "initial message not received")
1718 self.assertEquals(2, len(self.listener.messages))
1819
2526 listener2 = base.WaitableListener()
2627 listener2.reset(2)
2728 conn2.set_listener('', listener2)
28 conn2.subscribe(destination=d, ack='client',
29 headers={'prefetch-count': '10'})
29 self.subscribe_dest(conn2, destination, None,
30 ack='client',
31 headers={'prefetch-count': '10'})
3032 self.assertTrue(listener2.await(), "message not received again")
3133 self.assertEquals(2, len(listener2.messages))
3234
3335 # now ack only the last message - expecting cumulative behaviour
34 mid = listener2.messages[1]['headers']['message-id']
35 conn2.ack({'message-id':mid})
36 finally:
37 conn2.stop()
36 mid = listener2.messages[1]['headers'][self.ack_id_source_header]
37 self.ack_message(conn2, mid, None)
38 finally:
39 conn2.disconnect()
3840
3941 # now reconnect again, shouldn't see the message
4042 conn3 = self.create_connection()
4143 try:
4244 listener3 = base.WaitableListener()
4345 conn3.set_listener('', listener3)
44 conn3.subscribe(destination=d)
46 self.subscribe_dest(conn3, destination, None)
4547 self.assertFalse(listener3.await(3),
4648 "unexpected message. ACK not working?")
4749 finally:
48 conn3.stop()
50 conn3.disconnect()
4951
5052 def test_ack_client_individual(self):
51 d = "/queue/ack-test-individual"
53 destination = "/queue/ack-test-individual"
5254
5355 # subscribe and send message
5456 self.listener.reset(2) ## expecting 2 messages
55 self.conn.subscribe(destination=d, ack='client-individual',
57 self.subscribe_dest(self.conn, destination, None,
58 ack='client-individual',
5659 headers={'prefetch-count': '10'})
57 self.conn.send("test1", destination=d)
58 self.conn.send("test2", destination=d)
60 self.conn.send(destination, "test1")
61 self.conn.send(destination, "test2")
5962 self.assertTrue(self.listener.await(4), "Both initial messages not received")
6063 self.assertEquals(2, len(self.listener.messages))
6164
6871 listener2 = base.WaitableListener()
6972 listener2.reset(2) ## expect 2 messages
7073 conn2.set_listener('', listener2)
71 conn2.subscribe(destination=d, ack='client-individual',
72 headers={'prefetch-count': '10'})
74 self.subscribe_dest(conn2, destination, None,
75 ack='client-individual',
76 headers={'prefetch-count': '10'})
7377 self.assertTrue(listener2.await(2.5), "Did not receive 2 messages")
7478 self.assertEquals(2, len(listener2.messages), "Not exactly 2 messages received")
7579
7882 mid = None
7983 for ind in range(nummsgs):
8084 if listener2.messages[ind]['message']=="test2":
81 mid = listener2.messages[ind]['headers']['message-id']
85 mid = listener2.messages[ind]['headers'][self.ack_id_source_header]
8286 self.assertEquals(1, ind, 'Expecting test2 to be second message')
8387 break
8488 self.assertTrue(mid, "Did not find test2 message id.")
85 conn2.ack({'message-id':mid})
86 finally:
87 conn2.stop()
89 self.ack_message(conn2, mid, None)
90 finally:
91 conn2.disconnect()
8892
8993 # now reconnect again, shouldn't see the message
9094 conn3 = self.create_connection()
9296 listener3 = base.WaitableListener()
9397 listener3.reset(2) ## expecting a single message, but wait for two
9498 conn3.set_listener('', listener3)
95 conn3.subscribe(destination=d)
99 self.subscribe_dest(conn3, destination, None)
96100 self.assertFalse(listener3.await(2.5),
97101 "Expected to see only one message. ACK not working?")
98102 self.assertEquals(1, len(listener3.messages), "Expecting exactly one message")
99103 self.assertEquals("test1", listener3.messages[0]['message'], "Unexpected message remains")
100104 finally:
101 conn3.stop()
105 conn3.disconnect()
102106
103107 def test_ack_client_tx(self):
104 d = "/queue/ack-test-tx"
108 destination = "/queue/ack-test-tx"
105109
106110 # subscribe and send message
107111 self.listener.reset()
108 self.conn.subscribe(destination=d, ack='client')
109 self.conn.send("test", destination=d)
112 self.subscribe_dest(self.conn, destination, None, ack='client')
113 self.conn.send(destination, "test")
110114 self.assertTrue(self.listener.await(3), "initial message not received")
111115 self.assertEquals(1, len(self.listener.messages))
112116
120124 listener2 = base.WaitableListener()
121125 conn2.set_listener('', listener2)
122126 conn2.begin(transaction=tx)
123 conn2.subscribe(destination=d, ack='client')
127 self.subscribe_dest(conn2, destination, None, ack='client')
124128 self.assertTrue(listener2.await(), "message not received again")
125129 self.assertEquals(1, len(listener2.messages))
126130
127131 # now ack
128 mid = listener2.messages[0]['headers']['message-id']
129 conn2.ack({'message-id':mid, 'transaction':tx})
132 mid = listener2.messages[0]['headers'][self.ack_id_source_header]
133 self.ack_message(conn2, mid, None, transaction=tx)
130134
131135 #now commit
132136 conn2.commit(transaction=tx)
133137 finally:
134 conn2.stop()
138 conn2.disconnect()
135139
136140 # now reconnect again, shouldn't see the message
137141 conn3 = self.create_connection()
138142 try:
139143 listener3 = base.WaitableListener()
140144 conn3.set_listener('', listener3)
141 conn3.subscribe(destination=d)
145 self.subscribe_dest(conn3, destination, None)
142146 self.assertFalse(listener3.await(3),
143147 "unexpected message. TX ACK not working?")
144148 finally:
145 conn3.stop()
149 conn3.disconnect()
146150
147151 def test_topic_prefetch(self):
148 d = "/topic/prefetch-test"
152 destination = "/topic/prefetch-test"
149153
150154 # subscribe and send message
151155 self.listener.reset(6) ## expect 6 messages
152 self.conn.subscribe(destination=d, ack='client',
156 self.subscribe_dest(self.conn, destination, None,
157 ack='client',
153158 headers={'prefetch-count': '5'})
154159
155160 for x in range(10):
156 self.conn.send("test" + str(x), destination=d)
161 self.conn.send(destination, "test" + str(x))
157162
158163 self.assertFalse(self.listener.await(3),
159164 "Should not have been able to see 6 messages")
160165 self.assertEquals(5, len(self.listener.messages))
161166
162167 def test_nack(self):
163 d = "/queue/nack-test"
168 destination = "/queue/nack-test"
164169
165170 #subscribe and send
166 self.conn.subscribe(destination=d, ack='client-individual')
167 self.conn.send("nack-test", destination=d)
171 self.subscribe_dest(self.conn, destination, None,
172 ack='client-individual')
173 self.conn.send(destination, "nack-test")
168174
169175 self.assertTrue(self.listener.await(), "Not received message")
170 message_id = self.listener.messages[0]['headers']['message-id']
176 message_id = self.listener.messages[0]['headers'][self.ack_id_source_header]
171177 self.listener.reset()
172178
173 self.conn.send_frame("NACK", {"message-id" : message_id})
179 self.nack_message(self.conn, message_id, None)
174180 self.assertTrue(self.listener.await(), "Not received message after NACK")
175 message_id = self.listener.messages[0]['headers']['message-id']
176 self.conn.ack({'message-id' : message_id})
181 message_id = self.listener.messages[0]['headers'][self.ack_id_source_header]
182 self.ack_message(self.conn, message_id, None)
177183
178184 def test_nack_multi(self):
179 d = "/queue/nack-multi"
185 destination = "/queue/nack-multi"
180186
181187 self.listener.reset(2)
182188
183189 #subscribe and send
184 self.conn.subscribe(destination=d, ack='client',
190 self.subscribe_dest(self.conn, destination, None,
191 ack='client',
185192 headers = {'prefetch-count' : '10'})
186 self.conn.send("nack-test1", destination=d)
187 self.conn.send("nack-test2", destination=d)
193 self.conn.send(destination, "nack-test1")
194 self.conn.send(destination, "nack-test2")
188195
189196 self.assertTrue(self.listener.await(), "Not received messages")
190 message_id = self.listener.messages[1]['headers']['message-id']
197 message_id = self.listener.messages[1]['headers'][self.ack_id_source_header]
191198 self.listener.reset(2)
192199
193 self.conn.send_frame("NACK", {"message-id" : message_id})
200 self.nack_message(self.conn, message_id, None)
194201 self.assertTrue(self.listener.await(), "Not received message again")
195 message_id = self.listener.messages[1]['headers']['message-id']
196 self.conn.ack({'message-id' : message_id})
202 message_id = self.listener.messages[1]['headers'][self.ack_id_source_header]
203 self.ack_message(self.conn, message_id, None)
197204
198205 def test_nack_without_requeueing(self):
199 d = "/queue/nack-test-no-requeue"
200
201 self.conn.subscribe(destination=d, ack='client-individual')
202 self.conn.send("nack-test", destination=d)
206 destination = "/queue/nack-test-no-requeue"
207
208 self.subscribe_dest(self.conn, destination, None,
209 ack='client-individual')
210 self.conn.send(destination, "nack-test")
203211
204212 self.assertTrue(self.listener.await(), "Not received message")
205 message_id = self.listener.messages[0]['headers']['message-id']
213 message_id = self.listener.messages[0]['headers'][self.ack_id_source_header]
206214 self.listener.reset()
207215
208 self.conn.send_frame("NACK", {"message-id" : message_id, "requeue": False})
216 self.conn.send_frame("NACK", {self.ack_id_header: message_id, "requeue": False})
209217 self.assertFalse(self.listener.await(4), "Received message after NACK with requeue = False")
55
66 class BaseTest(unittest.TestCase):
77
8 def create_connection(self, version=None, heartbeat=None):
9 conn = stomp.Connection(user="guest", passcode="guest",
10 version=version, heartbeat=heartbeat)
8 def create_connection_obj(self, version='1.0', vhost='/', heartbeats=(0, 0)):
9 if version == '1.0':
10 conn = stomp.StompConnection10()
11 self.ack_id_source_header = 'message-id'
12 self.ack_id_header = 'message-id'
13 elif version == '1.1':
14 conn = stomp.StompConnection11(vhost=vhost,
15 heartbeats=heartbeats)
16 self.ack_id_source_header = 'message-id'
17 self.ack_id_header = 'message-id'
18 elif version == '1.2':
19 conn = stomp.StompConnection12(vhost=vhost,
20 heartbeats=heartbeats)
21 self.ack_id_source_header = 'ack'
22 self.ack_id_header = 'id'
23 else:
24 conn = stomp.StompConnection12(vhost=vhost,
25 heartbeats=heartbeats)
26 conn.version = version
27 return conn
28
29 def create_connection(self, user='guest', passcode='guest', wait=True, **kwargs):
30 conn = self.create_connection_obj(**kwargs)
1131 conn.start()
12 conn.connect()
32 conn.connect(user, passcode, wait=wait)
1333 return conn
34
35 def subscribe_dest(self, conn, destination, sub_id, **kwargs):
36 if type(conn) is stomp.StompConnection10:
37 # 'id' is optional in STOMP 1.0.
38 if sub_id != None:
39 kwargs['id'] = sub_id
40 conn.subscribe(destination, **kwargs)
41 else:
42 # 'id' is required in STOMP 1.1+.
43 if sub_id == None:
44 sub_id = 'ctag'
45 conn.subscribe(destination, sub_id, **kwargs)
46
47 def unsubscribe_dest(self, conn, destination, sub_id, **kwargs):
48 if type(conn) is stomp.StompConnection10:
49 # 'id' is optional in STOMP 1.0.
50 if sub_id != None:
51 conn.unsubscribe(id=sub_id, **kwargs)
52 else:
53 conn.unsubscribe(destination=destination, **kwargs)
54 else:
55 # 'id' is required in STOMP 1.1+.
56 if sub_id == None:
57 sub_id = 'ctag'
58 conn.unsubscribe(sub_id, **kwargs)
59
60 def ack_message(self, conn, msg_id, sub_id, **kwargs):
61 if type(conn) is stomp.StompConnection10:
62 conn.ack(msg_id, **kwargs)
63 elif type(conn) is stomp.StompConnection11:
64 if sub_id == None:
65 sub_id = 'ctag'
66 conn.ack(msg_id, sub_id, **kwargs)
67 elif type(conn) is stomp.StompConnection12:
68 conn.ack(msg_id, **kwargs)
69
70 def nack_message(self, conn, msg_id, sub_id, **kwargs):
71 if type(conn) is stomp.StompConnection10:
72 # Normally unsupported by STOMP 1.0.
73 conn.send_frame("NACK", {"message-id": msg_id})
74 elif type(conn) is stomp.StompConnection11:
75 if sub_id == None:
76 sub_id = 'ctag'
77 conn.nack(msg_id, sub_id, **kwargs)
78 elif type(conn) is stomp.StompConnection12:
79 conn.nack(msg_id, **kwargs)
1480
1581 def create_subscriber_connection(self, dest):
1682 conn = self.create_connection()
1783 listener = WaitableListener()
1884 conn.set_listener('', listener)
19 conn.subscribe(destination=dest, receipt="sub.receipt")
85 self.subscribe_dest(conn, dest, None, receipt="sub.receipt")
2086 listener.await()
2187 self.assertEquals(1, len(listener.receipts))
2288 listener.reset()
2995
3096 def tearDown(self):
3197 if self.conn.is_connected():
98 self.conn.disconnect()
3299 self.conn.stop()
33100
34101 def simple_test_send_rec(self, dest, route = None):
35102 self.listener.reset()
36103
37 self.conn.subscribe(destination=dest)
38 self.conn.send("foo", destination=dest)
104 self.subscribe_dest(self.conn, dest, None)
105 self.conn.send(dest, "foo")
39106
40107 self.assertTrue(self.listener.await(), "Timeout, no message received")
41108
1313 new_conn.set_listener('', listener)
1414
1515 new_conn.start() # not going to issue connect
16 new_conn.subscribe(destination="/topic/implicit", id='sub_implicit', receipt='implicit')
16 self.subscribe_dest(new_conn, "/topic/implicit", 'sub_implicit',
17 receipt='implicit')
1718
1819 try:
1920 self.assertTrue(listener.await(5))
2424 def test_invalid_exchange(self):
2525 ''' Test invalid exchange error '''
2626 self.listener.reset(1)
27 self.conn.subscribe(destination="/exchange/does.not.exist")
27 self.subscribe_dest(self.conn, "/exchange/does.not.exist", None,
28 ack="auto")
2829 self.assertListener("Expecting an error", numErrs=1)
2930 err = self.listener.errors[0]
3031 self.assertEquals("not_found", err['headers']['message'])
4849
4950 def test_send_receive(self):
5051 ''' Test basic send/receive for /queue '''
51 d = '/queue/test'
52 self.simple_test_send_rec(d)
52 destination = '/queue/test'
53 self.simple_test_send_rec(destination)
5354
5455 def test_send_receive_in_other_conn(self):
5556 ''' Test send in one connection, receive in another '''
56 d = '/queue/test2'
57 destination = '/queue/test2'
5758
5859 # send
59 self.conn.send("hello", destination=d)
60 self.conn.send(destination, "hello")
6061
6162 # now receive
6263 conn2 = self.create_connection()
6465 listener2 = base.WaitableListener()
6566 conn2.set_listener('', listener2)
6667
67 conn2.subscribe(destination=d)
68 self.subscribe_dest(conn2, destination, None, ack="auto")
6869 self.assertTrue(listener2.await(10), "no receive")
6970 finally:
70 conn2.stop()
71 conn2.disconnect()
7172
7273 def test_send_receive_in_other_conn_with_disconnect(self):
7374 ''' Test send, disconnect, receive '''
74 d = '/queue/test3'
75 destination = '/queue/test3'
7576
7677 # send
77 self.conn.send("hello thar", destination=d, receipt="foo")
78 self.conn.send(destination, "hello thar", receipt="foo")
7879 self.listener.await(3)
79 self.conn.stop()
80 self.conn.disconnect()
8081
8182 # now receive
8283 conn2 = self.create_connection()
8485 listener2 = base.WaitableListener()
8586 conn2.set_listener('', listener2)
8687
87 conn2.subscribe(destination=d)
88 self.subscribe_dest(conn2, destination, None, ack="auto")
8889 self.assertTrue(listener2.await(10), "no receive")
8990 finally:
90 conn2.stop()
91 conn2.disconnect()
9192
9293
9394 def test_multi_subscribers(self):
9495 ''' Test multiple subscribers against a single /queue destination '''
95 d = '/queue/test-multi'
96 destination = '/queue/test-multi'
9697
9798 ## set up two subscribers
98 conn1, listener1 = self.create_subscriber_connection(d)
99 conn2, listener2 = self.create_subscriber_connection(d)
99 conn1, listener1 = self.create_subscriber_connection(destination)
100 conn2, listener2 = self.create_subscriber_connection(destination)
100101
101102 try:
102103 ## now send
103 self.conn.send("test1", destination=d)
104 self.conn.send("test2", destination=d)
104 self.conn.send(destination, "test1")
105 self.conn.send(destination, "test2")
105106
106107 ## expect both consumers to get a message?
107108 self.assertTrue(listener1.await(2))
111112 self.assertEquals(1, len(listener2.messages),
112113 "unexpected message count")
113114 finally:
114 conn1.stop()
115 conn2.stop()
115 conn1.disconnect()
116 conn2.disconnect()
116117
117118 def test_send_with_receipt(self):
118 d = '/queue/test-receipt'
119 destination = '/queue/test-receipt'
119120 def noop(): pass
120 self.__test_send_receipt(d, noop, noop)
121 self.__test_send_receipt(destination, noop, noop)
121122
122123 def test_send_with_receipt_tx(self):
123 d = '/queue/test-receipt-tx'
124 destination = '/queue/test-receipt-tx'
124125 tx = 'receipt.tx'
125126
126127 def before():
130131 self.assertFalse(self.listener.await(1))
131132 self.conn.commit(transaction=tx)
132133
133 self.__test_send_receipt(d, before, after, {'transaction': tx})
134 self.__test_send_receipt(destination, before, after, {'transaction': tx})
134135
135136 def test_interleaved_receipt_no_receipt(self):
136137 ''' Test i-leaved receipt/no receipt, no-r bracketed by rs '''
137138
138 d = '/queue/ir'
139 destination = '/queue/ir'
139140
140141 self.listener.reset(5)
141142
142 self.conn.subscribe(destination=d)
143 self.conn.send('first', destination=d, receipt='a')
144 self.conn.send('second', destination=d)
145 self.conn.send('third', destination=d, receipt='b')
143 self.subscribe_dest(self.conn, destination, None, ack="auto")
144 self.conn.send(destination, 'first', receipt='a')
145 self.conn.send(destination, 'second')
146 self.conn.send(destination, 'third', receipt='b')
146147
147148 self.assertListener("Missing messages/receipts", numMsgs=3, numRcts=2, timeout=3)
148149
151152 def test_interleaved_receipt_no_receipt_tx(self):
152153 ''' Test i-leaved receipt/no receipt, no-r bracketed by r+xactions '''
153154
154 d = '/queue/ir'
155 destination = '/queue/ir'
155156 tx = 'tx.ir'
156157
157158 # three messages and two receipts
158159 self.listener.reset(5)
159160
160 self.conn.subscribe(destination=d)
161 self.subscribe_dest(self.conn, destination, None, ack="auto")
161162 self.conn.begin(transaction=tx)
162163
163 self.conn.send('first', destination=d, receipt='a', transaction=tx)
164 self.conn.send('second', destination=d, transaction=tx)
165 self.conn.send('third', destination=d, receipt='b', transaction=tx)
164 self.conn.send(destination, 'first', receipt='a', transaction=tx)
165 self.conn.send(destination, 'second', transaction=tx)
166 self.conn.send(destination, 'third', receipt='b', transaction=tx)
166167 self.conn.commit(transaction=tx)
167168
168169 self.assertListener("Missing messages/receipts", numMsgs=3, numRcts=2, timeout=40)
175176 def test_interleaved_receipt_no_receipt_inverse(self):
176177 ''' Test i-leaved receipt/no receipt, r bracketed by no-rs '''
177178
178 d = '/queue/ir'
179 destination = '/queue/ir'
179180
180181 self.listener.reset(4)
181182
182 self.conn.subscribe(destination=d)
183 self.conn.send('first', destination=d)
184 self.conn.send('second', destination=d, receipt='a')
185 self.conn.send('third', destination=d)
183 self.subscribe_dest(self.conn, destination, None, ack="auto")
184 self.conn.send(destination, 'first')
185 self.conn.send(destination, 'second', receipt='a')
186 self.conn.send(destination, 'third')
186187
187188 self.assertListener("Missing messages/receipt", numMsgs=3, numRcts=1, timeout=3)
188189
198199 for x in range(0, count):
199200 receipt = "test" + str(x)
200201 expected_receipts.add(receipt)
201 self.conn.send("test receipt", destination=destination,
202 self.conn.send(destination, "test receipt",
202203 receipt=receipt, headers=headers)
203204 after()
204205
220221
221222 def test_send_receive(self):
222223 ''' Test basic send/receive for /topic '''
223 d = '/topic/test'
224 self.simple_test_send_rec(d)
224 destination = '/topic/test'
225 self.simple_test_send_rec(destination)
225226
226227 def test_send_multiple(self):
227228 ''' Test /topic with multiple consumers '''
228 d = '/topic/multiple'
229 destination = '/topic/multiple'
229230
230231 ## set up two subscribers
231 conn1, listener1 = self.create_subscriber_connection(d)
232 conn2, listener2 = self.create_subscriber_connection(d)
232 conn1, listener1 = self.create_subscriber_connection(destination)
233 conn2, listener2 = self.create_subscriber_connection(destination)
233234
234235 try:
235236 ## listeners are expecting 2 messages
237238 listener2.reset(2)
238239
239240 ## now send
240 self.conn.send("test1", destination=d)
241 self.conn.send("test2", destination=d)
241 self.conn.send(destination, "test1")
242 self.conn.send(destination, "test2")
242243
243244 ## expect both consumers to get both messages
244245 self.assertTrue(listener1.await(5))
248249 self.assertEquals(2, len(listener2.messages),
249250 "unexpected message count")
250251 finally:
251 conn1.stop()
252 conn2.stop()
252 conn1.disconnect()
253 conn2.disconnect()
254
255 def test_send_multiple_with_a_large_message(self):
256 ''' Test /topic with multiple consumers '''
257 destination = '/topic/16mb'
258 # payload size
259 s = 1024 * 1024 * 16
260 message = 'x' * s
261
262 conn1, listener1 = self.create_subscriber_connection(destination)
263 conn2, listener2 = self.create_subscriber_connection(destination)
264
265 try:
266 listener1.reset(2)
267 listener2.reset(2)
268
269 self.conn.send(destination, message)
270 self.conn.send(destination, message)
271
272 self.assertTrue(listener1.await(10))
273 self.assertEquals(2, len(listener1.messages),
274 "unexpected message count")
275 self.assertTrue(len(listener2.messages[0]['message']) == s,
276 "unexpected message size")
277
278 self.assertTrue(listener2.await(10))
279 self.assertEquals(2, len(listener2.messages),
280 "unexpected message count")
281 finally:
282 conn1.disconnect()
283 conn2.disconnect()
253284
254285 class TestReplyQueue(base.BaseTest):
255286
267298 conn2, listener2 = self.create_subscriber_connection(known)
268299
269300 try:
270 self.conn.send("test", destination=known,
301 self.conn.send(known, "test",
271302 headers = {"reply-to": reply})
272303
273304 self.assertTrue(listener2.await(5))
276307 reply_to = listener2.messages[0]['headers']['reply-to']
277308 self.assertTrue(reply_to.startswith('/reply-queue/'))
278309
279 conn2.send("reply", destination=reply_to)
310 conn2.send(reply_to, "reply")
280311 self.assertTrue(self.listener.await(5))
281312 self.assertEquals("reply", self.listener.messages[0]['message'])
282313 finally:
283 conn2.stop()
314 conn2.disconnect()
284315
285316 def test_reuse_reply_queue(self):
286317 ''' Test re-use of reply-to queue '''
294325 self.assertEquals(1, len(listna.messages))
295326 reply_to = listna.messages[0]['headers']['reply-to']
296327 self.assertTrue(reply_to.startswith('/reply-queue/'))
297 cntn.send("reply", destination=reply_to)
328 cntn.send(reply_to, "reply")
298329
299330 ## Client 1 uses pre-supplied connection and listener
300331 ## Set up clients 2 and 3
302333 conn3, listener3 = self.create_subscriber_connection(known3)
303334 try:
304335 self.listener.reset(2)
305 self.conn.send("test2", destination=known2,
336 self.conn.send(known2, "test2",
306337 headers = {"reply-to": reply})
307 self.conn.send("test3", destination=known3,
338 self.conn.send(known3, "test3",
308339 headers = {"reply-to": reply})
309340 respond(conn2, listener2)
310341 respond(conn3, listener3)
314345 self.assertEquals("reply", self.listener.messages[0]['message'])
315346 self.assertEquals("reply", self.listener.messages[1]['message'])
316347 finally:
317 conn2.stop()
318 conn3.stop()
348 conn2.disconnect()
349 conn3.disconnect()
319350
320351 def test_perm_reply_queue(self):
321352 '''As test_reply_queue, but with a non-temp reply queue'''
329360 conn2, listener2 = self.create_subscriber_connection(known)
330361
331362 try:
332 conn1.send("test", destination=known,
363 conn1.send(known, "test",
333364 headers = {"reply-to": reply})
334365
335366 self.assertTrue(listener2.await(5))
338369 reply_to = listener2.messages[0]['headers']['reply-to']
339370 self.assertTrue(reply_to == reply)
340371
341 conn2.send("reply", destination=reply_to)
372 conn2.send(reply_to, "reply")
342373 self.assertTrue(listener1.await(5))
343374 self.assertEquals("reply", listener1.messages[0]['message'])
344375 finally:
345 conn1.stop()
346 conn2.stop()
376 conn1.disconnect()
377 conn2.disconnect()
347378
348379 class TestDurableSubscription(base.BaseTest):
349380
355386 if not id:
356387 id = TestDurableSubscription.ID
357388
358 conn.subscribe(destination=dest,
359 headers ={'persistent': 'true',
360 'receipt': 1,
361 'id': id})
389 self.subscribe_dest(conn, dest, id, ack="auto",
390 headers = {'persistent': 'true',
391 'receipt': 1})
362392
363393 def __assert_receipt(self, listener=None, pos=None):
364394 if not listener:
380410 self.assertEquals(pos, self.listener.messages[0]['msg_no'])
381411
382412 def test_durable_subscription(self):
383 d = '/topic/durable'
384
385 self.__subscribe(d)
413 destination = '/topic/durable'
414
415 self.__subscribe(destination)
386416 self.__assert_receipt()
387417
388418 # send first message without unsubscribing
389419 self.listener.reset(1)
390 self.conn.send("first", destination=d)
420 self.conn.send(destination, "first")
391421 self.__assert_message("first")
392422
393423 # now unsubscribe (disconnect only)
394 self.conn.unsubscribe(id=TestDurableSubscription.ID)
424 self.unsubscribe_dest(self.conn, destination, TestDurableSubscription.ID)
395425
396426 # send again
397427 self.listener.reset(2)
398 self.conn.send("second", destination=d)
428 self.conn.send(destination, "second")
399429
400430 # resubscribe and expect receipt
401 self.__subscribe(d)
431 self.__subscribe(destination)
402432 self.__assert_receipt(pos=1)
403433 # and message
404434 self.__assert_message("second", pos=2)
405435
406436 # now unsubscribe (cancel)
407 self.conn.unsubscribe(id=TestDurableSubscription.ID,
437 self.unsubscribe_dest(self.conn, destination, TestDurableSubscription.ID,
408438 headers={'persistent': 'true'})
409439
410440 # send again
411441 self.listener.reset(1)
412 self.conn.send("third", destination=d)
442 self.conn.send(destination, "third")
413443
414444 # resubscribe and expect no message
415 self.__subscribe(d)
445 self.__subscribe(destination)
416446 self.assertTrue(self.listener.await(3))
417447 self.assertEquals(0, len(self.listener.messages))
418448 self.assertEquals(1, len(self.listener.receipts))
419449
420450 def test_share_subscription(self):
421 d = '/topic/durable-shared'
451 destination = '/topic/durable-shared'
422452
423453 conn2 = self.create_connection()
424454 conn2.set_listener('', self.listener)
425455
426456 try:
427 self.__subscribe(d)
457 self.__subscribe(destination)
428458 self.__assert_receipt()
429459 self.listener.reset(1)
430 self.__subscribe(d, conn2)
460 self.__subscribe(destination, conn2)
431461 self.__assert_receipt()
432462
433463 self.listener.reset(100)
434464
435465 # send 100 messages
436466 for x in xrange(0, 100):
437 self.conn.send("msg" + str(x), destination=d)
467 self.conn.send(destination, "msg" + str(x))
438468
439469 self.assertTrue(self.listener.await(5))
440470 self.assertEquals(100, len(self.listener.messages))
441471 finally:
442 conn2.stop()
472 conn2.disconnect()
443473
444474 def test_separate_ids(self):
445 d = '/topic/durable-separate'
475 destination = '/topic/durable-separate'
446476
447477 conn2 = self.create_connection()
448478 listener2 = base.WaitableListener()
450480
451481 try:
452482 # ensure durable subscription exists for each ID
453 self.__subscribe(d)
483 self.__subscribe(destination)
454484 self.__assert_receipt()
455 self.__subscribe(d, conn2, "other.id")
485 self.__subscribe(destination, conn2, "other.id")
456486 self.__assert_receipt(listener2)
457 self.conn.unsubscribe(id=TestDurableSubscription.ID)
458 conn2.unsubscribe(id="other.id")
487 self.unsubscribe_dest(self.conn, destination, TestDurableSubscription.ID)
488 self.unsubscribe_dest(conn2, destination, "other.id")
459489
460490 self.listener.reset(101)
461491 listener2.reset(101) ## 100 messages and 1 receipt
462492
463493 # send 100 messages
464494 for x in xrange(0, 100):
465 self.conn.send("msg" + str(x), destination=d)
466
467 self.__subscribe(d)
468 self.__subscribe(d, conn2, "other.id")
495 self.conn.send(destination, "msg" + str(x))
496
497 self.__subscribe(destination)
498 self.__subscribe(destination, conn2, "other.id")
469499
470500 for l in [self.listener, listener2]:
471501 self.assertTrue(l.await(20))
472502 self.assertEquals(100, len(l.messages))
473503
474504 finally:
475 conn2.stop()
505 conn2.disconnect()
476506
477507 def test_durable_subscribe_no_id(self):
478 d = '/topic/durable-invalid'
479
480 self.conn.subscribe(destination=d, headers={'persistent':'true'}),
508 destination = '/topic/durable-invalid'
509
510 self.conn.send_frame('SUBSCRIBE',
511 {'destination': destination, 'ack': 'auto', 'persistent': 'true'})
481512 self.listener.await(3)
482513 self.assertEquals(1, len(self.listener.errors))
483514 self.assertEquals("Missing Header", self.listener.errors[0]['headers']['message'])
484
485
2727
2828 def test_unknown_destination(self):
2929 self.listener.reset()
30 self.conn.send(destination="/something/interesting")
30 self.conn.send("/something/interesting", 'test_unknown_destination')
3131
3232 self.assertTrue(self.listener.await())
3333 self.assertEquals(1, len(self.listener.errors))
5353
5454 def __test_invalid_destination(self, dtype, content):
5555 self.listener.reset()
56 self.conn.send(destination="/" + dtype + content)
56 self.conn.send("/" + dtype + content, '__test_invalid_destination:' + dtype + content)
5757
5858 self.assertTrue(self.listener.await())
5959 self.assertEquals(1, len(self.listener.errors))
4444 d = "/queue/unsub04"
4545 self.unsub_test(d, self.sub_and_send(d, subid="queid", receipt="unsub.rct"), numRcts=1)
4646
47 def test_connect_version_1_0(self):
48 ''' Test CONNECT with version 1.0'''
49 self.conn.disconnect()
50 new_conn = self.create_connection(version="1.0")
51 try:
52 self.assertTrue(new_conn.is_connected())
53 finally:
54 new_conn.disconnect()
55 self.assertFalse(new_conn.is_connected())
56
4757 def test_connect_version_1_1(self):
4858 ''' Test CONNECT with version 1.1'''
4959 self.conn.disconnect()
5464 new_conn.disconnect()
5565 self.assertFalse(new_conn.is_connected())
5666
67 def test_connect_version_1_2(self):
68 ''' Test CONNECT with version 1.2'''
69 self.conn.disconnect()
70 new_conn = self.create_connection(version="1.2")
71 try:
72 self.assertTrue(new_conn.is_connected())
73 finally:
74 new_conn.disconnect()
75 self.assertFalse(new_conn.is_connected())
76
5777 def test_heartbeat_disconnects_client(self):
5878 ''' Test heart-beat disconnection'''
5979 self.conn.disconnect()
60 new_conn = self.create_connection(heartbeat="1500,0")
80 new_conn = self.create_connection(version='1.1', heartbeats=(1500, 0))
6181 try:
6282 self.assertTrue(new_conn.is_connected())
6383 time.sleep(1)
7090
7191 def test_unsupported_version(self):
7292 ''' Test unsupported version on CONNECT command'''
73 self.bad_connect(stomp.Connection(user="guest",
74 passcode="guest",
75 version="100.1"),
76 "Supported versions are 1.0,1.1,1.2\n")
93 self.bad_connect("Supported versions are 1.0,1.1,1.2\n", version='100.1')
7794
7895 def test_bad_username(self):
7996 ''' Test bad username'''
80 self.bad_connect(stomp.Connection(user="gust",
81 passcode="guest"),
82 "Access refused for user 'gust'\n")
97 self.bad_connect("Access refused for user 'gust'\n", user='gust')
8398
8499 def test_bad_password(self):
85100 ''' Test bad password'''
86 self.bad_connect(stomp.Connection(user="guest",
87 passcode="gust"),
88 "Access refused for user 'guest'\n")
101 self.bad_connect("Access refused for user 'guest'\n", passcode='gust')
89102
90103 def test_bad_vhost(self):
91104 ''' Test bad virtual host'''
92 self.bad_connect(stomp.Connection(user="guest",
93 passcode="guest",
94 virtual_host="//"),
95 "Virtual host '//' access denied")
105 self.bad_connect("Virtual host '//' access denied", version='1.1', vhost='//')
96106
97 def bad_connect(self, new_conn, expected):
107 def bad_connect(self, expected, user='guest', passcode='guest', **kwargs):
98108 self.conn.disconnect()
109 new_conn = self.create_connection_obj(**kwargs)
99110 listener = base.WaitableListener()
100111 new_conn.set_listener('', listener)
101112 try:
102113 new_conn.start()
103 new_conn.connect()
114 new_conn.connect(user, passcode)
104115 self.assertTrue(listener.await())
105116 self.assertEquals(expected, listener.errors[0]['message'])
106117 finally:
135146
136147 def unsub_test(self, dest, verbs, numRcts=0):
137148 def afterfun():
138 self.conn.send("after-test", destination=dest)
149 self.conn.send(dest, "after-test")
139150 subverb, unsubverb = verbs
140151 self.assertListenerAfter(subverb, numMsgs=1,
141152 errMsg="FAILED to subscribe and send")
144155 self.assertListenerAfter(afterfun,
145156 errMsg="Still receiving messages")
146157
147 def sub_and_send(self, dest, subid="", receipt=""):
158 def sub_and_send(self, dest, subid=None, receipt=None):
148159 def subfun():
149 if subid=="":
150 self.conn.subscribe(destination=dest)
151 else:
152 self.conn.subscribe(destination=dest, id=subid)
153 self.conn.send("test", destination=dest)
160 self.subscribe_dest(self.conn, dest, subid)
161 self.conn.send(dest, "test")
154162 def unsubfun():
155 if subid=="" and receipt=="":
156 self.conn.unsubscribe(destination=dest)
157 elif receipt=="":
158 self.conn.unsubscribe(id=subid)
159 elif subid=="":
160 self.conn.unsubscribe(destination=dest, receipt=receipt)
161 else:
162 self.conn.unsubscribe(id=subid, receipt=receipt)
163 headers = {}
164 if receipt != None:
165 headers['receipt'] = receipt
166 self.unsubscribe_dest(self.conn, dest, subid, **headers)
163167 return subfun, unsubfun
5050
5151
5252 def match(self, pattern, data):
53 ''' helper: try to match 'pattern' regexp with 'data' string.
54 Fail test if they don't match.
53 ''' helper: try to match a regexp with a string.
54 Fail test if they do not match.
5555 '''
5656 matched = re.match(pattern, data)
5757 if matched:
194194 '\n\x00')
195195 for cd in [self.cd1, self.cd2]:
196196 self.match(resp, cd.recv(4096))
197
198
199 @connect(['cd'])
200 def test_huge_message(self):
201 ''' Test sending/receiving huge (16MB) message. '''
202 subscribe=( 'SUBSCRIBE\n'
203 'id: xxx\n'
204 'destination:/exchange/amq.topic/test_huge_message\n'
205 '\n\0')
206 self.cd.sendall(subscribe)
207
208 message = 'x' * 1024*1024*16
209
210 self.cd.sendall('SEND\n'
211 'destination:/exchange/amq.topic/test_huge_message\n'
212 'content-type:text/plain\n'
213 '\n'
214 '%s'
215 '\0' % message)
216
217 resp=('MESSAGE\n'
218 'subscription:(.*)\n'
219 'destination:/topic/test_huge_message\n'
220 'message-id:(.*)\n'
221 'content-type:text/plain\n'
222 'content-length:%i\n'
223 '\n'
224 '%s(.*)'
225 % (len(message), message[:8000]) )
226
227 recv = []
228 s = 0
229 while len(recv) < 1 or recv[-1][-1] != '\0':
230 buf = self.cd.recv(4096*16)
231 s += len(buf)
232 recv.append( buf )
233 buf = ''.join(recv)
234
235 # matching 100MB regexp is way too expensive.
236 self.match(resp, buf[:8192])
237 self.assertEqual(len(buf) > len(message), True)
238197
239198 @connect(['cd'])
240199 def test_message_with_embedded_nulls(self):
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_amqqueue_test).
3333
3434 run() ->
3535 [put(K, 0) || K <- [sent, recd, last_sent, last_recd]],
36 put(last_ts, erlang:now()),
36 put(last_ts, os:timestamp()),
3737 {ok, Pub} = rabbit_stomp_client:connect(),
3838 {ok, Recv} = rabbit_stomp_client:connect(),
3939 Self = self(),
40 spawn(fun() -> publish(Self, Pub, 0, erlang:now()) end),
40 spawn(fun() -> publish(Self, Pub, 0, os:timestamp()) end),
4141 rabbit_stomp_client:send(
4242 Recv, "SUBSCRIBE", [{"destination", ?DESTINATION}]),
43 spawn(fun() -> recv(Self, Recv, 0, erlang:now()) end),
43 spawn(fun() -> recv(Self, Recv, 0, os:timestamp()) end),
4444 report().
4545
4646 report() ->
4848 {sent, C} -> put(sent, C);
4949 {recd, C} -> put(recd, C)
5050 end,
51 Diff = timer:now_diff(erlang:now(), get(last_ts)),
51 Diff = timer:now_diff(os:timestamp(), get(last_ts)),
5252 case Diff > ?MICROS_PER_UPDATE of
5353 true -> S = get(sent) - get(last_sent),
5454 R = get(recd) - get(last_recd),
5555 put(last_sent, get(sent)),
5656 put(last_recd, get(recd)),
57 put(last_ts, erlang:now()),
57 put(last_ts, os:timestamp()),
5858 io:format("Send ~p msg/s | Recv ~p msg/s~n",
5959 [trunc(S * ?MICROS_PER_SECOND / Diff),
6060 trunc(R * ?MICROS_PER_SECOND / Diff)]);
6666 rabbit_stomp_client:send(
6767 Client, "SEND", [{"destination", ?DESTINATION}],
6868 [integer_to_list(Count)]),
69 Diff = timer:now_diff(erlang:now(), TS),
69 Diff = timer:now_diff(os:timestamp(), TS),
7070 case Diff > ?MICROS_PER_UPDATE_MSG of
7171 true -> Owner ! {sent, Count + 1},
72 publish(Owner, Client, Count + 1, erlang:now());
72 publish(Owner, Client, Count + 1, os:timestamp());
7373 false -> publish(Owner, Client, Count + 1, TS)
7474 end.
7575
7878 rabbit_stomp_client:recv(Client0),
7979 BodyInt = list_to_integer(binary_to_list(iolist_to_binary(Body))),
8080 Count = BodyInt,
81 Diff = timer:now_diff(erlang:now(), TS),
81 Diff = timer:now_diff(os:timestamp(), TS),
8282 case Diff > ?MICROS_PER_UPDATE_MSG of
8383 true -> Owner ! {recd, Count + 1},
84 recv(Owner, Client1, Count + 1, erlang:now());
84 recv(Owner, Client1, Count + 1, os:timestamp());
8585 false -> recv(Owner, Client1, Count + 1, TS)
8686 end.
8787
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_test).
2323
2424 all_tests() ->
2525 test_messages_not_dropped_on_disconnect(),
26 test_direct_client_connections_are_not_leaked(),
27 ok.
28
29 -define(GARBAGE, <<"bdaf63dda9d78b075c748b740e7c3510ad203b07\nbdaf63dd">>).
30
31 count_connections() ->
32 length(supervisor2:which_children(rabbit_stomp_client_sup_sup)).
33
34 test_direct_client_connections_are_not_leaked() ->
35 N = count_connections(),
36 lists:foreach(fun (_) ->
37 {ok, Client = {Socket, _}} = rabbit_stomp_client:connect(),
38 %% send garbage which trips up the parser
39 gen_tcp:send(Socket, ?GARBAGE),
40 rabbit_stomp_client:send(
41 Client, "LOL", [{"", ""}])
42 end,
43 lists:seq(1, 1000)),
44 timer:sleep(5000),
45 N = count_connections(),
2646 ok.
2747
2848 test_messages_not_dropped_on_disconnect() ->
49 N = count_connections(),
2950 {ok, Client} = rabbit_stomp_client:connect(),
51 N1 = N + 1,
52 N1 = count_connections(),
3053 [rabbit_stomp_client:send(
3154 Client, "SEND", [{"destination", ?DESTINATION}],
3255 [integer_to_list(Count)]) || Count <- lists:seq(1, 1000)],
3356 rabbit_stomp_client:disconnect(Client),
3457 QName = rabbit_misc:r(<<"/">>, queue, <<"bulk-test">>),
3558 timer:sleep(3000),
59 N = count_connections(),
3660 rabbit_amqqueue:with(
3761 QName, fun(Q) ->
3862 1000 = pget(messages, rabbit_amqqueue:info(Q, [messages]))
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_test_frame).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_stomp_test_util).
66
77 def test_send_and_disconnect(self):
88 ''' Test close socket after send does not lose messages '''
9 d = "/queue/reliability"
9 destination = "/queue/reliability"
1010 pub_conn = self.create_connection()
1111 try:
1212 msg = "0" * (128)
1616 listener = base.WaitableListener()
1717 listener.reset(count)
1818 self.conn.set_listener('', listener)
19 self.conn.subscribe(destination=d)
19 self.subscribe_dest(self.conn, destination, None)
2020
2121 for x in range(0, count):
22 pub_conn.send(msg + str(x), destination=d)
22 pub_conn.send(destination, msg + str(x))
2323 time.sleep(2.0)
24 pub_conn.close_socket()
24 pub_conn.disconnect()
2525
2626 if listener.await(30):
2727 self.assertEquals(count, len(listener.messages))
44
55 import stomp
66 import base
7 import ssl
78
89
910 base_path = os.path.dirname(sys.argv[0])
1516 class TestSslClient(unittest.TestCase):
1617
1718 def __ssl_connect(self):
18 conn = stomp.Connection(user="guest", passcode="guest",
19 host_and_ports = [ ('localhost', 61614) ],
19 conn = stomp.Connection(host_and_ports = [ ('localhost', 61614) ],
2020 use_ssl = True, ssl_key_file = ssl_key_file,
2121 ssl_cert_file = ssl_cert_file,
2222 ssl_ca_certs = ssl_ca_certs)
2323 print "FILE: ", ssl_cert_file
2424 conn.start()
25 conn.connect()
25 conn.connect("guest", "guest")
2626 return conn
2727
2828 def __ssl_auth_connect(self):
3636
3737 def test_ssl_connect(self):
3838 conn = self.__ssl_connect()
39 conn.stop()
39 conn.disconnect()
4040
4141 def test_ssl_auth_connect(self):
4242 conn = self.__ssl_auth_connect()
43 conn.stop()
43 conn.disconnect()
4444
4545 def test_ssl_send_receive(self):
4646 conn = self.__ssl_connect()
5757 conn.set_listener('', listener)
5858
5959 d = "/topic/ssl.test"
60 conn.subscribe(destination=d, receipt="sub")
60 conn.subscribe(destination=d, ack="auto", id="ctag", receipt="sub")
6161
6262 self.assertTrue(listener.await(1))
6363
6565 listener.receipts[0]['headers']['receipt-id'])
6666
6767 listener.reset(1)
68 conn.send("Hello SSL!", destination=d)
68 conn.send(body="Hello SSL!", destination=d)
6969
7070 self.assertTrue(listener.await())
7171
22 import test_runner
33
44 if __name__ == '__main__':
5 modules = ['parsing', 'destinations', 'lifecycle', 'transactions',
6 'ack', 'errors', 'reliability']
5 modules = [
6 'parsing',
7 'destinations',
8 'lifecycle',
9 'transactions',
10 'ack',
11 'errors',
12 'reliability',
13 ]
714 test_runner.run_unittests(modules)
815
66
77 def test_tx_commit(self):
88 ''' Test TX with a COMMIT and ensure messages are delivered '''
9 d = "/exchange/amq.fanout"
9 destination = "/exchange/amq.fanout"
1010 tx = "test.tx"
1111
1212 self.listener.reset()
13 self.conn.subscribe(destination=d)
13 self.subscribe_dest(self.conn, destination, None)
1414 self.conn.begin(transaction=tx)
15 self.conn.send("hello!", destination=d, transaction=tx)
16 self.conn.send("again!", destination=d)
15 self.conn.send(destination, "hello!", transaction=tx)
16 self.conn.send(destination, "again!")
1717
1818 ## should see the second message
1919 self.assertTrue(self.listener.await(3))
3030
3131 def test_tx_abort(self):
3232 ''' Test TX with an ABORT and ensure messages are discarded '''
33 d = "/exchange/amq.fanout"
33 destination = "/exchange/amq.fanout"
3434 tx = "test.tx"
3535
3636 self.listener.reset()
37 self.conn.subscribe(destination=d)
37 self.subscribe_dest(self.conn, destination, None)
3838 self.conn.begin(transaction=tx)
39 self.conn.send("hello!", destination=d, transaction=tx)
40 self.conn.send("again!", destination=d)
39 self.conn.send(destination, "hello!", transaction=tx)
40 self.conn.send(destination, "again!")
4141
4242 ## should see the second message
4343 self.assertTrue(self.listener.await(3))
204204 Q = Q0#amqqueue{arguments = [{<<"x-max-priority">>, long, 5}]},
205205 PQ = rabbit_priority_queue,
206206 BQS1 = PQ:init(Q, new, fun(_, _) -> ok end),
207 {Duration1, BQS2} = PQ:ram_duration(BQS1),
207 {_Duration1, BQS2} = PQ:ram_duration(BQS1),
208208 BQS3 = PQ:set_ram_duration_target(infinity, BQS2),
209209 BQS4 = PQ:set_ram_duration_target(1, BQS3),
210 {Duration2, BQS5} = PQ:ram_duration(BQS4),
210 {_Duration2, BQS5} = PQ:ram_duration(BQS4),
211211 PQ:delete_and_terminate(a_whim, BQS5),
212212 passed.
213213
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_app).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_consumer).
1010 %% The Original Code is RabbitMQ Federation.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_consumer_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_files).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_mgmt).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_traces).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414
1515 -module(rabbit_tracing_wm_file).
1616
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_wm_files).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414
1515 -module(rabbit_tracing_wm_trace).
1616
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_wm_traces).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_tracing_test).
2929 [Head, Body] = binary:split(Frame, <<"\n\n">>),
3030 [Command | HeaderLines] = binary:split(Head, <<"\n">>, [global]),
3131 Headers = [list_to_tuple(binary:split(Line, <<":">>)) || Line <- HeaderLines],
32 [Body1, <<>>] = binary:split(Body, [<<0>>],[{scope,{byte_size(Body)-1, 1}}]),
32 [Body1, <<>>] = binary:split(Body, [<<0, 10>>],[{scope,{byte_size(Body)-2, 2}}]),
3333 {Command, Headers, Body1}.
3434
3535 %% ----------
1111 ## The Original Code is RabbitMQ.
1212 ##
1313 ## The Initial Developer of the Original Code is GoPivotal, Inc.
14 ## Copyright (c) 2012-2014 GoPivotal, Inc. All rights reserved.
14 ## Copyright (c) 2012-2015 Pivotal Software, Inc. All rights reserved.
1515 ##
1616
1717 ### next line potentially updated in package install steps
2525
2626 ## Set default values
2727
28 BOOT_MODULE="rabbit"
29
2830 CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq
2931 LOG_BASE=${SYS_PREFIX}/var/log/rabbitmq
3032 MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia
3133 ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/rabbitmq/enabled_plugins
3234
3335 PLUGINS_DIR="${RABBITMQ_HOME}/plugins"
36 IO_THREAD_POOL_SIZE=64
3437
3538 CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf
0 @echo off
1
2 REM ### next line potentially updated in package install steps
3 REM set SYS_PREFIX=
4
5 REM ### next line will be updated when generating a standalone release
6 REM ERL_DIR=
7 set ERL_DIR=
8
9 REM These boot files don't appear to be referenced in the batch scripts
10 REM set CLEAN_BOOT_FILE=start_clean
11 REM set SASL_BOOT_FILE=start_sasl
12
13 REM ## Set default values
14
15 if "!RABBITMQ_BASE!"=="" (
16 set RABBITMQ_BASE=!APPDATA!\RabbitMQ
17 )
18
19 REM BOOT_MODULE="rabbit"
20 REM CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq
21 REM LOG_BASE=${SYS_PREFIX}/var/log/rabbitmq
22 REM MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia
23 REM ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/rabbitmq/enabled_plugins
24 set BOOT_MODULE=rabbit
25 set CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq
26 set LOG_BASE=!RABBITMQ_BASE!\log
27 set MNESIA_BASE=!RABBITMQ_BASE!\db
28 set ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins
29
30 REM PLUGINS_DIR="${RABBITMQ_HOME}/plugins"
31 set PLUGINS_DIR=!TDP0!..\plugins
32
33 REM CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf
34 if "!RABBITMQ_CONF_ENV_FILE!"=="" (
35 set CONF_ENV_FILE=!APPDATA!\RabbitMQ\rabbitmq-env-conf.bat
36 )
44 REM <rabbitmq_nodename> (s)name of the erlang node to connect to (required)
55
66 setlocal
7
8 set TDP0=%~dp0
9
10 REM Get default settings with user overrides for (RABBITMQ_)<var_name>
11 REM Non-empty defaults should be set in rabbitmq-env
12 call "!TDP0!\rabbitmq-env.bat"
713
814 if "%1"=="" goto fail
915
1622 if not exist "%WMIC_PATH%" (
1723 goto fail
1824 )
19
20 :: sets sname/name ::
21 if "!RABBITMQ_USE_LONGNAME!"=="" (
22 set RABBITMQ_NAME_TYPE="-sname"
23 )
24
25 if "!RABBITMQ_USE_LONGNAME!"=="true" (
26 set RABBITMQ_NAME_TYPE="-name"
27 )
28
2925
3026 :getpid
3127 for /f "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%%RABBITMQ_NAME_TYPE% %1%%'" get processid 2^>nul`) do (
1111 ## The Original Code is RabbitMQ.
1212 ##
1313 ## The Initial Developer of the Original Code is GoPivotal, Inc.
14 ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 ##
1616
1717 # We set +e here since since our test for "readlink -f" below needs to
4343 . ${SCRIPT_DIR}/rabbitmq-defaults
4444
4545 ## Common defaults
46 SERVER_ERL_ARGS="+K true +A30 +P 1048576 \
47 -kernel inet_default_connect_options [{nodelay,true}]"
46 SERVER_ERL_ARGS="+P 1048576"
4847
4948 # warn about old rabbitmq.conf file, if no new one
5049 if [ -f /etc/rabbitmq/rabbitmq.conf ] && \
5352 echo "location has moved to ${CONF_ENV_FILE}"
5453 fi
5554
55 # We save the current value of $RABBITMQ_PID_FILE in case it was set by
56 # an init script. If $CONF_ENV_FILE overrides it again, we must ignore
57 # it and warn the user.
58 saved_RABBITMQ_PID_FILE=$RABBITMQ_PID_FILE
59
5660 ## Get configuration variables from the configure environment file
5761 [ -f ${CONF_ENV_FILE} ] && . ${CONF_ENV_FILE} || true
62
63 if [ "$saved_RABBITMQ_PID_FILE" -a \
64 "$saved_RABBITMQ_PID_FILE" != "$RABBITMQ_PID_FILE" ]; then
65 echo "WARNING: RABBITMQ_PID_FILE was already set by the init script to:" 1>&2
66 echo " $saved_RABBITMQ_PID_FILE" 1>&2
67 echo " The value set in rabbitmq-env.conf is ignored because it" 1>&2
68 echo " would break the init script." 1>&2
69
70 RABBITMQ_PID_FILE="$saved_RABBITMQ_PID_FILE"
71 fi
5872
5973 [ "x" = "x$RABBITMQ_USE_LONGNAME" ] && RABBITMQ_USE_LONGNAME=${USE_LONGNAME}
6074 if [ "xtrue" = "x$RABBITMQ_USE_LONGNAME" ] ; then
6983
7084 ##--- Set environment vars RABBITMQ_<var_name> to defaults if not set
7185
86 rmq_realpath() {
87 local path=$1
88
89 if [ -d "$path" ]; then
90 cd "$path" && pwd
91 elif [ -f "$path" ]; then
92 cd "$(dirname "$path")" && echo $(pwd)/$(basename "$path")
93 else
94 echo "$path"
95 fi
96 }
97
98 rmq_check_if_shared_with_mnesia() {
99 local var
100
101 local mnesia_dir=$(rmq_realpath "${RABBITMQ_MNESIA_DIR}")
102 local prefix="WARNING:"
103
104 for var in "$@"; do
105 local dir=$(eval "echo \"\$$var\"")
106
107 case $(rmq_realpath "$dir") in
108 ${mnesia_dir})
109 warning=1
110 echo "$prefix $var is equal to RABBITMQ_MNESIA_DIR" 1>&2
111 ;;
112 ${mnesia_dir}/*)
113 warning=1
114 echo "$prefix $var is located inside RABBITMQ_MNESIA_DIR" 1>&2
115 ;;
116 esac
117
118 if [ "x$warning" = "x1" ]; then
119 prefix=" "
120 fi
121 done
122
123 if [ "x$warning" = "x1" ]; then
124 echo "$prefix => Auto-clustering will not work ('cluster_nodes' in rabbitmq.config)" 1>&2
125 fi
126 }
127
72128 DEFAULT_NODE_IP_ADDRESS=auto
73129 DEFAULT_NODE_PORT=5672
74130 [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS}
82138 [ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${RABBITMQ_NODE_PORT} + 20000))
83139
84140 [ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME}
141 [ "x" = "x$RABBITMQ_IO_THREAD_POOL_SIZE" ] && RABBITMQ_IO_THREAD_POOL_SIZE=${IO_THREAD_POOL_SIZE}
85142 [ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS}
86143 [ "x" = "x$RABBITMQ_CONFIG_FILE" ] && RABBITMQ_CONFIG_FILE=${CONFIG_FILE}
87144 [ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=${LOG_BASE}
93150
94151 [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${PID_FILE}
95152 [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${RABBITMQ_MNESIA_DIR}.pid
153
154 [ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE}
96155
97156 [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${PLUGINS_EXPAND_DIR}
98157 [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME}-plugins-expand
109168
110169 [ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS=${CTL_ERL_ARGS}
111170
171 # Check if files and directories non-related to Mnesia are configured
172 # to be in $RABBITMQ_MNESIA_DIR. If this is the case, issue a warning
173 # because it will prevent auto-clustering from working (the node will be
174 # considered non-virgin).
175
176 rmq_check_if_shared_with_mnesia \
177 RABBITMQ_CONFIG_FILE \
178 RABBITMQ_LOG_BASE \
179 RABBITMQ_PID_FILE \
180 RABBITMQ_PLUGINS_EXPAND_DIR \
181 RABBITMQ_ENABLED_PLUGINS_FILE \
182 RABBITMQ_PLUGINS_DIR \
183 RABBITMQ_LOGS \
184 RABBITMQ_SASL_LOGS
185
112186 ##--- End of overridden <var_name> variables
113187
114188 # Since we source this elsewhere, don't accidentally stop execution
0 @echo off
1
2 REM Scopes the variables to the current batch file
3 REM setlocal
4
5 rem Preserve values that might contain exclamation marks before
6 rem enabling delayed expansion
7 set TDP0=%~dp0
8 REM setlocal enabledelayedexpansion
9
10 REM SCRIPT_DIR=`dirname $SCRIPT_PATH`
11 REM RABBITMQ_HOME="${SCRIPT_DIR}/.."
12 set SCRIPT_DIR=%TDP0%
13 set RABBITMQ_HOME=%SCRIPT_DIR%..
14
15 REM ## Set defaults
16 REM . ${SCRIPT_DIR}/rabbitmq-defaults
17 call "%SCRIPT_DIR%\rabbitmq-defaults.bat"
18
19 REM These common defaults aren't referenced in the batch scripts
20 REM ## Common defaults
21 REM SERVER_ERL_ARGS="+P 1048576"
22 REM
23 REM # warn about old rabbitmq.conf file, if no new one
24 REM if [ -f /etc/rabbitmq/rabbitmq.conf ] && \
25 REM [ ! -f ${CONF_ENV_FILE} ] ; then
26 REM echo -n "WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- "
27 REM echo "location has moved to ${CONF_ENV_FILE}"
28 REM fi
29
30 REM ERL_ARGS aren't referenced in the batch scripts
31 REM Common defaults
32 REM set SERVER_ERL_ARGS=+P 1048576
33
34 REM ## Get configuration variables from the configure environment file
35 REM [ -f ${CONF_ENV_FILE} ] && . ${CONF_ENV_FILE} || true
36 if exist "!RABBITMQ_CONF_ENV_FILE!" (
37 call !RABBITMQ_CONF_ENV_FILE!
38 )
39
40 REM Check for the short names here too
41 if "!RABBITMQ_USE_LONGNAME!"=="" (
42 if "!USE_LONGNAME!"=="" (
43 set RABBITMQ_NAME_TYPE="-sname"
44 )
45 )
46
47 if "!RABBITMQ_USE_LONGNAME!"=="true" (
48 if "!USE_LONGNAME!"=="true" (
49 set RABBITMQ_NAME_TYPE="-name"
50 )
51 )
52
53 if "!COMPUTERNAME!"=="" (
54 set COMPUTERNAME=localhost
55 )
56
57 REM [ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME}
58 if "!RABBITMQ_NODENAME!"=="" (
59 if "!NODENAME!"=="" (
60 set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME!
61 ) else (
62 set RABBITMQ_NODENAME=!NODENAME!
63 )
64 )
65
66 REM
67 REM ##--- Set environment vars RABBITMQ_<var_name> to defaults if not set
68 REM
69 REM DEFAULT_NODE_IP_ADDRESS=auto
70 REM DEFAULT_NODE_PORT=5672
71 REM [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS}
72 REM [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${NODE_PORT}
73 REM [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_IP_ADDRESS=${DEFAULT_NODE_IP_ADDRESS}
74 REM [ "x" != "x$RABBITMQ_NODE_IP_ADDRESS" ] && [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${DEFAULT_NODE_PORT}
75
76 REM if "!RABBITMQ_NODE_IP_ADDRESS!"=="" (
77 REM if not "!RABBITMQ_NODE_PORT!"=="" (
78 REM set RABBITMQ_NODE_IP_ADDRESS=auto
79 REM )
80 REM ) else (
81 REM if "!RABBITMQ_NODE_PORT!"=="" (
82 REM set RABBITMQ_NODE_PORT=5672
83 REM )
84 REM )
85
86 REM DOUBLE CHECK THIS LOGIC
87 if "!RABBITMQ_NODE_IP_ADDRESS!"=="" (
88 if "!NODE_IP_ADDRESS!"=="" (
89 set RABBITMQ_NODE_IP_ADDRESS=auto
90 ) else (
91 set RABBITMQ_NODE_IP_ADDRESS=!NODE_IP_ADDRESS!
92 )
93 )
94
95 if "!RABBITMQ_NODE_PORT!"=="" (
96 if "!NODE_PORT!"=="" (
97 set RABBITMQ_NODE_PORT=5672
98 ) else (
99 set RABBITMQ_NODE_PORT=!NODE_PORT!
100 )
101 )
102
103 REM [ "x" = "x$RABBITMQ_DIST_PORT" ] && RABBITMQ_DIST_PORT=${DIST_PORT}
104 REM [ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${DEFAULT_NODE_PORT} + 20000))
105 REM [ "x" = "x$RABBITMQ_DIST_PORT" ] && [ "x" != "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_DIST_PORT=$((${RABBITMQ_NODE_PORT} + 20000))
106
107 if "!RABBITMQ_DIST_PORT!"=="" (
108 if "!DIST_PORT!"=="" (
109 if "!RABBITMQ_NODE_PORT!"=="" (
110 set RABBITMQ_DIST_PORT=25672
111 ) else (
112 set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT!
113 )
114 ) else (
115 set RABBITMQ_DIST_PORT=!DIST_PORT!
116 )
117 )
118
119 REM [ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS}
120 REM No Windows equivalent
121
122 REM [ "x" = "x$RABBITMQ_CONFIG_FILE" ] && RABBITMQ_CONFIG_FILE=${CONFIG_FILE}
123 if "!RABBITMQ_CONFIG_FILE!"=="" (
124 if "!CONFIG_FILE!"=="" (
125 set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq
126 ) else (
127 set RABBITMQ_CONFIG_FILE=!CONFIG_FILE!
128 )
129 )
130
131 REM [ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=${LOG_BASE}
132 if "!RABBITMQ_LOG_BASE!"=="" (
133 if "!LOG_BASE!"=="" (
134 set RABBITMQ_LOG_BASE=!RABBITMQ_BASE!\log
135 ) else (
136 set RABBITMQ_LOG_BASE=!LOG_BASE!
137 )
138 )
139
140 REM [ "x" = "x$RABBITMQ_MNESIA_BASE" ] && RABBITMQ_MNESIA_BASE=${MNESIA_BASE}
141 if "!RABBITMQ_MNESIA_BASE!"=="" (
142 if "!MNESIA_BASE!"=="" (
143 set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!\db
144 ) else (
145 set RABBITMQ_MNESIA_BASE=!MNESIA_BASE!
146 )
147 )
148
149 REM [ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS=${SERVER_START_ARGS}
150 REM No Windows equivalent
151
152 REM [ "x" = "x$RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS" ] && RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=${SERVER_ADDITIONAL_ERL_ARGS}
153 REM No Windows equivalent
154
155 REM [ "x" = "x$RABBITMQ_MNESIA_DIR" ] && RABBITMQ_MNESIA_DIR=${MNESIA_DIR}
156 REM [ "x" = "x$RABBITMQ_MNESIA_DIR" ] && RABBITMQ_MNESIA_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME}
157 if "!RABBITMQ_MNESIA_DIR!"=="" (
158 if "!MNESIA_DIR!"=="" (
159 set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia
160 ) else (
161 set RABBITMQ_MNESIA_DIR=!MNESIA_DIR!
162 )
163 )
164
165 REM [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${PID_FILE}
166 REM [ "x" = "x$RABBITMQ_PID_FILE" ] && RABBITMQ_PID_FILE=${RABBITMQ_MNESIA_DIR}.pid
167 REM No Windows equivalent
168
169 REM [ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE}
170 if "!RABBITMQ_BOOT_MODULE!"=="" (
171 if "!BOOT_MODULE!"=="" (
172 set RABBITMQ_BOOT_MODULE=rabbit
173 ) else (
174 set RABBITMQ_BOOT_MODULE=!BOOT_MODULE!
175 )
176 )
177
178 REM [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${PLUGINS_EXPAND_DIR}
179 REM [ "x" = "x$RABBITMQ_PLUGINS_EXPAND_DIR" ] && RABBITMQ_PLUGINS_EXPAND_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME}-plugins-expand
180 if "!RABBITMQ_PLUGINS_EXPAND_DIR!"=="" (
181 if "!PLUGINS_EXPAND_DIR!"=="" (
182 set RABBITMQ_PLUGINS_EXPAND_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-plugins-expand
183 ) else (
184 set RABBITMQ_PLUGINS_EXPAND_DIR=!PLUGINS_EXPAND_DIR!
185 )
186 )
187
188 REM [ "x" = "x$RABBITMQ_ENABLED_PLUGINS_FILE" ] && RABBITMQ_ENABLED_PLUGINS_FILE=${ENABLED_PLUGINS_FILE}
189 if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" (
190 if "!ENABLED_PLUGINS_FILE!"=="" (
191 set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins
192 ) else (
193 set RABBITMQ_ENABLED_PLUGINS_FILE=!ENABLED_PLUGINS_FILE!
194 )
195 )
196
197 REM [ "x" = "x$RABBITMQ_PLUGINS_DIR" ] && RABBITMQ_PLUGINS_DIR=${PLUGINS_DIR}
198 if "!RABBITMQ_PLUGINS_DIR!"=="" (
199 if "!PLUGINS_DIR!"=="" (
200 set RABBITMQ_PLUGINS_DIR=!RABBITMQ_BASE!\plugins
201 ) else (
202 set RABBITMQ_PLUGINS_DIR=!PLUGINS_DIR!
203 )
204 )
205
206 REM ## Log rotation
207 REM [ "x" = "x$RABBITMQ_LOGS" ] && RABBITMQ_LOGS=${LOGS}
208 REM [ "x" = "x$RABBITMQ_LOGS" ] && RABBITMQ_LOGS="${RABBITMQ_LOG_BASE}/${RABBITMQ_NODENAME}.log"
209 if "!RABBITMQ_LOGS!"=="" (
210 if "!LOGS!"=="" (
211 set LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!.log
212 ) else (
213 set LOGS=!LOGS!
214 )
215 )
216
217 REM [ "x" = "x$RABBITMQ_SASL_LOGS" ] && RABBITMQ_SASL_LOGS=${SASL_LOGS}
218 REM [ "x" = "x$RABBITMQ_SASL_LOGS" ] && RABBITMQ_SASL_LOGS="${RABBITMQ_LOG_BASE}/${RABBITMQ_NODENAME}-sasl.log"
219 if "!RABBITMQ_SASL_LOGS!"=="" (
220 if "!SASL_LOGS!"=="" (
221 set SASL_LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!-sasl.log
222 ) else (
223 set SASL_LOGS=!SASL_LOGS!
224 )
225 )
226
227 REM [ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS=${CTL_ERL_ARGS}
228 if "!$RABBITMQ_CTL_ERL_ARGS!"=="" (
229 if not "!CTL_ERL_ARGS!"=="" (
230 set RABBITMQ_CTL_ERL_ARGS=!CTL_ERL_ARGS!
231 )
232 )
233
234 REM ADDITIONAL WINDOWS ONLY CONFIG ITEMS
235 REM rabbitmq-plugins.bat
236 REM if "!RABBITMQ_SERVICENAME!"=="" (
237 REM set RABBITMQ_SERVICENAME=RabbitMQ
238 REM )
239
240 if "!RABBITMQ_SERVICENAME!"=="" (
241 if "!SERVICENAME!"=="" (
242 set RABBITMQ_SERVICENAME=RabbitMQ
243 ) else (
244 set RABBITMQ_SERVICENAME=!SERVICENAME!
245 )
246 )
247
248 REM ##--- End of overridden <var_name> variables
249 REM
250 REM # Since we source this elsewhere, don't accidentally stop execution
251 REM true
1111 ## The Original Code is RabbitMQ.
1212 ##
1313 ## The Initial Developer of the Original Code is GoPivotal, Inc.
14 ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 ##
1616
1717 # Get default settings with user overrides for (RABBITMQ_)<var_name>
00 @echo off
1
12 REM The contents of this file are subject to the Mozilla Public License
23 REM Version 1.1 (the "License"); you may not use this file except in
34 REM compliance with the License. You may obtain a copy of the License
1112 REM The Original Code is RabbitMQ.
1213 REM
1314 REM The Initial Developer of the Original Code is GoPivotal, Inc.
14 REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
15 REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1516 REM
1617
1718 setlocal
2223 set STAR=%*
2324 setlocal enabledelayedexpansion
2425
25 if "!RABBITMQ_SERVICENAME!"=="" (
26 set RABBITMQ_SERVICENAME=RabbitMQ
27 )
28
29 if "!RABBITMQ_BASE!"=="" (
30 set RABBITMQ_BASE=!APPDATA!\!RABBITMQ_SERVICENAME!
31 )
32
33 if "!RABBITMQ_NODENAME!"=="" (
34 set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME!
35 )
26 REM Get default settings with user overrides for (RABBITMQ_)<var_name>
27 REM Non-empty defaults should be set in rabbitmq-env
28 call "!TDP0!\rabbitmq-env.bat"
3629
3730 if not exist "!ERLANG_HOME!\bin\erl.exe" (
3831 echo.
4437 echo RabbitMQ server distribution in the Erlang lib folder.
4538 echo.
4639 exit /B 1
47 )
48
49 if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" (
50 set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins
51 )
52
53 if "!RABBITMQ_PLUGINS_DIR!"=="" (
54 set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins
5540 )
5641
5742 "!ERLANG_HOME!\bin\erl.exe" ^
1111 ## The Original Code is RabbitMQ.
1212 ##
1313 ## The Initial Developer of the Original Code is GoPivotal, Inc.
14 ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 ##
1616
1717 # Get default settings with user overrides for (RABBITMQ_)<var_name>
2020
2121 RABBITMQ_START_RABBIT=
2222 [ "x" = "x$RABBITMQ_ALLOW_INPUT" ] && RABBITMQ_START_RABBIT=" -noinput"
23 [ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -s rabbit boot "
23 [ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -s $RABBITMQ_BOOT_MODULE boot "
2424
2525 case "$(uname -s)" in
2626 CYGWIN*) # we make no attempt to record the cygwin pid; rabbitmqctl wait
7575 RABBITMQ_LISTEN_ARG=
7676 [ "x" != "x$RABBITMQ_NODE_PORT" ] && [ "x" != "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_LISTEN_ARG="-rabbit tcp_listeners [{\""${RABBITMQ_NODE_IP_ADDRESS}"\","${RABBITMQ_NODE_PORT}"}]"
7777
78 # If $RABBITMQ_LOGS is '-', send all log messages to stdout. Likewise
79 # for RABBITMQ_SASL_LOGS. This is particularily useful for Docker
80 # images.
81
82 if [ "$RABBITMQ_LOGS" = '-' ]; then
83 RABBIT_ERROR_LOGGER='tty'
84 else
85 RABBIT_ERROR_LOGGER='{file,"'${RABBITMQ_LOGS}'"}'
86 fi
87
88 if [ "$RABBITMQ_SASL_LOGS" = '-' ]; then
89 SASL_ERROR_LOGGER=tty
90 RABBIT_SASL_ERROR_LOGGER='tty'
91 else
92 SASL_ERROR_LOGGER=false
93 RABBIT_SASL_ERROR_LOGGER='{file,"'${RABBITMQ_SASL_LOGS}'"}'
94 fi
95
7896 # we need to turn off path expansion because some of the vars, notably
7997 # RABBITMQ_SERVER_ERL_ARGS, contain terms that look like globs and
8098 # there is no other way of preventing their expansion.
88106 -boot "${SASL_BOOT_FILE}" \
89107 ${RABBITMQ_CONFIG_ARG} \
90108 +W w \
109 +A ${RABBITMQ_IO_THREAD_POOL_SIZE} \
91110 ${RABBITMQ_SERVER_ERL_ARGS} \
111 +K true \
112 -kernel inet_default_connect_options "[{nodelay,true}]" \
92113 ${RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS} \
93114 ${RABBITMQ_LISTEN_ARG} \
94115 -sasl errlog_type error \
95 -sasl sasl_error_logger false \
96 -rabbit error_logger '{file,"'${RABBITMQ_LOGS}'"}' \
97 -rabbit sasl_error_logger '{file,"'${RABBITMQ_SASL_LOGS}'"}' \
116 -sasl sasl_error_logger "$SASL_ERROR_LOGGER" \
117 -rabbit error_logger "$RABBIT_ERROR_LOGGER" \
118 -rabbit sasl_error_logger "$RABBIT_SASL_ERROR_LOGGER" \
98119 -rabbit enabled_plugins_file "\"$RABBITMQ_ENABLED_PLUGINS_FILE\"" \
99120 -rabbit plugins_dir "\"$RABBITMQ_PLUGINS_DIR\"" \
100121 -rabbit plugins_expand_dir "\"$RABBITMQ_PLUGINS_EXPAND_DIR\"" \
1111 REM The Original Code is RabbitMQ.
1212 REM
1313 REM The Initial Developer of the Original Code is GoPivotal, Inc.
14 REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 REM
1616
1717 setlocal
2222 set STAR=%*
2323 setlocal enabledelayedexpansion
2424
25 if "!RABBITMQ_USE_LONGNAME!"=="" (
26 set RABBITMQ_NAME_TYPE="-sname"
27 )
28
29 if "!RABBITMQ_USE_LONGNAME!"=="true" (
30 set RABBITMQ_NAME_TYPE="-name"
31 )
32
33 if "!RABBITMQ_BASE!"=="" (
34 set RABBITMQ_BASE=!APPDATA!\RabbitMQ
35 )
36
37 if "!COMPUTERNAME!"=="" (
38 set COMPUTERNAME=localhost
39 )
40
41 if "!RABBITMQ_NODENAME!"=="" (
42 set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME!
43 )
44
45 if "!RABBITMQ_NODE_IP_ADDRESS!"=="" (
46 if not "!RABBITMQ_NODE_PORT!"=="" (
47 set RABBITMQ_NODE_IP_ADDRESS=auto
48 )
49 ) else (
50 if "!RABBITMQ_NODE_PORT!"=="" (
51 set RABBITMQ_NODE_PORT=5672
52 )
53 )
54
55 if "!RABBITMQ_DIST_PORT!"=="" (
56 if "!RABBITMQ_NODE_PORT!"=="" (
57 set RABBITMQ_DIST_PORT=25672
58 ) else (
59 set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT!
60 )
61 )
25 REM Get default settings with user overrides for (RABBITMQ_)<var_name>
26 REM Non-empty defaults should be set in rabbitmq-env
27 call "%TDP0%\rabbitmq-env.bat"
6228
6329 if not exist "!ERLANG_HOME!\bin\erl.exe" (
6430 echo.
7036 echo RabbitMQ server distribution in the Erlang lib folder.
7137 echo.
7238 exit /B 1
73 )
74
75 if "!RABBITMQ_MNESIA_BASE!"=="" (
76 set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!/db
77 )
78 if "!RABBITMQ_LOG_BASE!"=="" (
79 set RABBITMQ_LOG_BASE=!RABBITMQ_BASE!/log
80 )
81
82
83 rem We save the previous logs in their respective backup
84 rem Log management (rotation, filtering based of size...) is left as an exercice for the user.
85
86 set LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!.log
87 set SASL_LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!-sasl.log
88
89 rem End of log management
90
91
92 if "!RABBITMQ_MNESIA_DIR!"=="" (
93 set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia
94 )
95
96 if "!RABBITMQ_PLUGINS_EXPAND_DIR!"=="" (
97 set RABBITMQ_PLUGINS_EXPAND_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-plugins-expand
98 )
99
100 if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" (
101 set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins
102 )
103
104 if "!RABBITMQ_PLUGINS_DIR!"=="" (
105 set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins
10639 )
10740
10841 set RABBITMQ_EBIN_ROOT=!TDP0!..\ebin
12457
12558 set RABBITMQ_EBIN_PATH="-pa !RABBITMQ_EBIN_ROOT!"
12659
127 if "!RABBITMQ_CONFIG_FILE!"=="" (
128 set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq
129 )
130
13160 if exist "!RABBITMQ_CONFIG_FILE!.config" (
13261 set RABBITMQ_CONFIG_ARG=-config "!RABBITMQ_CONFIG_FILE!"
13362 ) else (
14372
14473 set RABBITMQ_START_RABBIT=
14574 if "!RABBITMQ_NODE_ONLY!"=="" (
146 set RABBITMQ_START_RABBIT=-s rabbit boot
75 set RABBITMQ_START_RABBIT=-s "!RABBITMQ_BOOT_MODULE!" boot
76 )
77
78 if "!RABBITMQ_IO_THREAD_POOL_SIZE!"=="" (
79 set RABBITMQ_IO_THREAD_POOL_ARG=30
14780 )
14881
14982 "!ERLANG_HOME!\bin\erl.exe" ^
15487 !RABBITMQ_CONFIG_ARG! ^
15588 !RABBITMQ_NAME_TYPE! !RABBITMQ_NODENAME! ^
15689 +W w ^
157 +A30 ^
90 +A "!RABBITMQ_IO_THREAD_POOL_SIZE!" ^
15891 +P 1048576 ^
159 -kernel inet_default_connect_options "[{nodelay, true}]" ^
16092 !RABBITMQ_LISTEN_ARG! ^
16193 !RABBITMQ_SERVER_ERL_ARGS! ^
94 -kernel inet_default_connect_options "[{nodelay, true}]" ^
16295 !RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS! ^
16396 -sasl errlog_type error ^
16497 -sasl sasl_error_logger false ^
1111 REM The Original Code is RabbitMQ.
1212 REM
1313 REM The Initial Developer of the Original Code is GoPivotal, Inc.
14 REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 REM
1616
1717 setlocal
2222 set TDP0=%~dp0
2323 set P1=%1
2424 setlocal enabledelayedexpansion
25
26 REM Get default settings with user overrides for (RABBITMQ_)<var_name>
27 REM Non-empty defaults should be set in rabbitmq-env
28 call "%TDP0%\rabbitmq-env.bat"
2529
2630 set STARVAR=
2731 shift
3135 shift
3236 goto loop1
3337 :after_loop
34
35 if "!RABBITMQ_USE_LONGNAME!"=="" (
36 set RABBITMQ_NAME_TYPE="-sname"
37 )
38
39 if "!RABBITMQ_USE_LONGNAME!"=="true" (
40 set RABBITMQ_NAME_TYPE="-name"
41 )
42
43 if "!RABBITMQ_SERVICENAME!"=="" (
44 set RABBITMQ_SERVICENAME=RabbitMQ
45 )
46
47 if "!RABBITMQ_BASE!"=="" (
48 set RABBITMQ_BASE=!APPDATA!\!RABBITMQ_SERVICENAME!
49 )
50
51 if "!COMPUTERNAME!"=="" (
52 set COMPUTERNAME=localhost
53 )
54
55 if "!RABBITMQ_NODENAME!"=="" (
56 set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME!
57 )
58
59 if "!RABBITMQ_NODE_IP_ADDRESS!"=="" (
60 if not "!RABBITMQ_NODE_PORT!"=="" (
61 set RABBITMQ_NODE_IP_ADDRESS=auto
62 )
63 ) else (
64 if "!RABBITMQ_NODE_PORT!"=="" (
65 set RABBITMQ_NODE_PORT=5672
66 )
67 )
68
69 if "!RABBITMQ_DIST_PORT!"=="" (
70 if "!RABBITMQ_NODE_PORT!"=="" (
71 set RABBITMQ_DIST_PORT=25672
72 ) else (
73 set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT!
74 )
75 )
7638
7739 if "!ERLANG_SERVICE_MANAGER_PATH!"=="" (
7840 if not exist "!ERLANG_HOME!\bin\erl.exe" (
11274 exit /B 1
11375 )
11476
115 if "!RABBITMQ_MNESIA_BASE!"=="" (
116 set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!/db
117 )
118 if "!RABBITMQ_LOG_BASE!"=="" (
119 set RABBITMQ_LOG_BASE=!RABBITMQ_BASE!/log
120 )
121
122
123 rem We save the previous logs in their respective backup
124 rem Log management (rotation, filtering based on size...) is left as an exercise for the user.
125
126 set LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!.log
127 set SASL_LOGS=!RABBITMQ_LOG_BASE!\!RABBITMQ_NODENAME!-sasl.log
128
129 rem End of log management
130
131
132 if "!RABBITMQ_MNESIA_DIR!"=="" (
133 set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia
134 )
135
136 if "!RABBITMQ_PLUGINS_EXPAND_DIR!"=="" (
137 set RABBITMQ_PLUGINS_EXPAND_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-plugins-expand
138 )
139
14077 if "!P1!" == "install" goto INSTALL_SERVICE
14178 for %%i in (start stop disable enable list remove) do if "%%i" == "!P1!" goto MODIFY_SERVICE
14279
173110 echo !RABBITMQ_SERVICENAME! service is already present - only updating service parameters
174111 )
175112
176 if "!RABBITMQ_ENABLED_PLUGINS_FILE!"=="" (
177 set RABBITMQ_ENABLED_PLUGINS_FILE=!RABBITMQ_BASE!\enabled_plugins
178 )
179
180 if "!RABBITMQ_PLUGINS_DIR!"=="" (
181 set RABBITMQ_PLUGINS_DIR=!TDP0!..\plugins
182 )
183
184113 set RABBITMQ_EBIN_ROOT=!TDP0!..\ebin
185
186 if "!RABBITMQ_CONFIG_FILE!"=="" (
187 set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq
188 )
189114
190115 "!ERLANG_HOME!\bin\erl.exe" ^
191116 -pa "!RABBITMQ_EBIN_ROOT!" ^
223148 set RABBITMQ_START_RABBIT=-s rabbit boot
224149 )
225150
151 if "!RABBITMQ_IO_THREAD_POOL_SIZE!"=="" (
152 set RABBITMQ_IO_THREAD_POOL_SIZE=30
153 )
154
226155 set ERLANG_SERVICE_ARGUMENTS= ^
227156 -pa "!RABBITMQ_EBIN_ROOT!" ^
157 -boot start_sasl ^
228158 !RABBITMQ_START_RABBIT! ^
229 -s rabbit boot ^
230159 !RABBITMQ_CONFIG_ARG! ^
231160 +W w ^
232 +A30 ^
161 +A "!RABBITMQ_IO_THREAD_POOL_SIZE!" ^
233162 +P 1048576 ^
234163 -kernel inet_default_connect_options "[{nodelay,true}]" ^
235164 !RABBITMQ_LISTEN_ARG! ^
1111 ## The Original Code is RabbitMQ.
1212 ##
1313 ## The Initial Developer of the Original Code is GoPivotal, Inc.
14 ## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 ## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 ##
1616
1717 # Get default settings with user overrides for (RABBITMQ_)<var_name>
1111 REM The Original Code is RabbitMQ.
1212 REM
1313 REM The Initial Developer of the Original Code is GoPivotal, Inc.
14 REM Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
14 REM Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1515 REM
1616
17 REM Scopes the variables to the current batch file
1718 setlocal
1819
1920 rem Preserve values that might contain exclamation marks before
2122 set TDP0=%~dp0
2223 set STAR=%*
2324 setlocal enabledelayedexpansion
24
25 if "!RABBITMQ_BASE!"=="" (
26 set RABBITMQ_BASE=!APPDATA!\RabbitMQ
27 )
28
29 if "!COMPUTERNAME!"=="" (
30 set COMPUTERNAME=localhost
31 )
32
33 if "!RABBITMQ_NODENAME!"=="" (
34 set RABBITMQ_NODENAME=rabbit@!COMPUTERNAME!
35 )
36
37 if "!RABBITMQ_MNESIA_BASE!"=="" (
38 set RABBITMQ_MNESIA_BASE=!RABBITMQ_BASE!/db
39 )
40
41 if "!RABBITMQ_MNESIA_DIR!"=="" (
42 set RABBITMQ_MNESIA_DIR=!RABBITMQ_MNESIA_BASE!/!RABBITMQ_NODENAME!-mnesia
43 )
4425
4526 if not exist "!ERLANG_HOME!\bin\erl.exe" (
4627 echo.
5334 echo.
5435 exit /B 1
5536 )
37
38 REM Get default settings with user overrides for (RABBITMQ_)<var_name>
39 REM Non-empty defaults should be set in rabbitmq-env
40 call "%TDP0%\rabbitmq-env.bat"
5641
5742 "!ERLANG_HOME!\bin\erl.exe" ^
5843 -pa "!TDP0!..\ebin" ^
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515 -module(app_utils).
1616
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(background_gc).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(credit_flow).
6767 put(Key, Expr)
6868 end).
6969
70 %% If current process was blocked by credit flow in the last
71 %% STATE_CHANGE_INTERVAL milliseconds, state/0 will report it as "in
72 %% flow".
73 -define(STATE_CHANGE_INTERVAL, 1000000).
74
7075 %%----------------------------------------------------------------------------
7176
7277 %% There are two "flows" here; of messages and of credit, going in
116121 false -> case get(credit_blocked_at) of
117122 undefined -> running;
118123 B -> Diff = timer:now_diff(erlang:now(), B),
119 case Diff < 5000000 of
124 case Diff < ?STATE_CHANGE_INTERVAL of
120125 true -> flow;
121126 false -> running
122127 end
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(delegate).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(delegate_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% A dual-index tree.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(file_handle_cache).
147147 copy/3, set_maximum_since_use/1, delete/1, clear/1]).
148148 -export([obtain/0, obtain/1, release/0, release/1, transfer/1, transfer/2,
149149 set_limit/1, get_limit/0, info_keys/0, with_handle/1, with_handle/2,
150 info/0, info/1]).
150 info/0, info/1, clear_read_cache/0]).
151151 -export([ulimit/0]).
152152
153153 -export([start_link/0, start_link/2, init/1, handle_call/3, handle_cast/2,
162162 -define(OBTAIN_LIMIT(LIMIT), trunc((LIMIT * 0.9) - 2)).
163163 -define(CLIENT_ETS_TABLE, file_handle_cache_client).
164164 -define(ELDERS_ETS_TABLE, file_handle_cache_elders).
165
166 -include("rabbit.hrl"). % For #amqqueue record definition.
165167
166168 %%----------------------------------------------------------------------------
167169
352354 read_buffer_rem = BufRem - Count,
353355 read_buffer_usage = BufUsg + Count }]};
354356 ([Handle0]) ->
357 maybe_reduce_read_cache([Ref]),
355358 Handle = #handle{read_buffer = Buf,
356359 read_buffer_pos = BufPos,
357360 read_buffer_rem = BufRem,
579582 info() -> info(?INFO_KEYS).
580583 info(Items) -> gen_server2:call(?SERVER, {info, Items}, infinity).
581584
585 clear_read_cache() ->
586 gen_server2:cast(?SERVER, clear_read_cache),
587 clear_vhost_read_cache(rabbit_vhost:list()).
588
589 clear_vhost_read_cache([]) ->
590 ok;
591 clear_vhost_read_cache([VHost | Rest]) ->
592 clear_queue_read_cache(rabbit_amqqueue:list(VHost)),
593 clear_vhost_read_cache(Rest).
594
595 clear_queue_read_cache([]) ->
596 ok;
597 clear_queue_read_cache([#amqqueue{pid = MPid, slave_pids = SPids} | Rest]) ->
598 %% Limit the action to the current node.
599 Pids = [P || P <- [MPid | SPids], node(P) =:= node()],
600 %% This function is executed in the context of the backing queue
601 %% process because the read buffer is stored in the process
602 %% dictionary.
603 Fun = fun(_, State) ->
604 clear_process_read_cache(),
605 State
606 end,
607 [rabbit_amqqueue:run_backing_queue(Pid, rabbit_variable_queue, Fun)
608 || Pid <- Pids],
609 clear_queue_read_cache(Rest).
610
611 clear_process_read_cache() ->
612 [
613 begin
614 Handle1 = reset_read_buffer(Handle),
615 put({Ref, fhc_handle}, Handle1)
616 end ||
617 {{Ref, fhc_handle}, Handle} <- get(),
618 size(Handle#handle.read_buffer) > 0
619 ].
620
582621 %%----------------------------------------------------------------------------
583622 %% Internal functions
584623 %%----------------------------------------------------------------------------
9611000 false -> Usg * 2
9621001 end, Lim)}.
9631002
1003 maybe_reduce_read_cache(SparedRefs) ->
1004 case rabbit_memory_monitor:memory_use(bytes) of
1005 {_, infinity} -> ok;
1006 {MemUse, MemLimit} when MemUse < MemLimit -> ok;
1007 {MemUse, MemLimit} -> reduce_read_cache(
1008 (MemUse - MemLimit) * 2,
1009 SparedRefs)
1010 end.
1011
1012 reduce_read_cache(MemToFree, SparedRefs) ->
1013 Handles = lists:sort(
1014 fun({_, H1}, {_, H2}) -> H1 < H2 end,
1015 [{R, H} || {{R, fhc_handle}, H} <- get(),
1016 not lists:member(R, SparedRefs)
1017 andalso size(H#handle.read_buffer) > 0]),
1018 FreedMem = lists:foldl(
1019 fun
1020 (_, Freed) when Freed >= MemToFree ->
1021 Freed;
1022 ({Ref, #handle{read_buffer = Buf} = Handle}, Freed) ->
1023 Handle1 = reset_read_buffer(Handle),
1024 put({Ref, fhc_handle}, Handle1),
1025 Freed + size(Buf)
1026 end, 0, Handles),
1027 if
1028 FreedMem < MemToFree andalso SparedRefs =/= [] ->
1029 reduce_read_cache(MemToFree - FreedMem, []);
1030 true ->
1031 ok
1032 end.
1033
9641034 infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items].
9651035
9661036 i(total_limit, #fhc_state{limit = Limit}) -> Limit;
11141184 {noreply, process_pending(
11151185 update_counts({obtain, socket}, ToPid, +N,
11161186 update_counts({obtain, socket}, FromPid, -N,
1117 State)))}.
1187 State)))};
1188
1189 handle_cast(clear_read_cache, State) ->
1190 clear_process_read_cache(),
1191 {noreply, State}.
11181192
11191193 handle_info(check_counts, State) ->
11201194 {noreply, maybe_reduce(State #fhc_state { timer_ref = undefined })};
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(file_handle_cache_stats).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(gatherer).
575575 {ok, State, Timeout, Backoff = {backoff, _, _, _}, Mod1} ->
576576 Backoff1 = extend_backoff(Backoff),
577577 proc_lib:init_ack(Starter, {ok, self()}),
578 loop(GS2State #gs2_state { mod = Mod1,
579 state = State,
580 time = Timeout,
581 timeout_state = Backoff1 });
578 loop(find_prioritisers(
579 GS2State #gs2_state { mod = Mod1,
580 state = State,
581 time = Timeout,
582 timeout_state = Backoff1 }));
582583 {stop, Reason} ->
583584 %% For consistency, we must make sure that the
584585 %% registered name (if any) is unregistered before
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(gm).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(lqueue).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(mirrored_supervisor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(mirrored_supervisor_sups).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(mnesia_sync).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(pmon).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% Priority queues have essentially the same interface as ordinary
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit).
3939 {requires, pre_boot},
4040 {enables, external_infrastructure}]}).
4141
42 %% rabbit_alarm currently starts memory and disk space monitors
43 -rabbit_boot_step({rabbit_alarm,
44 [{description, "alarm handler"},
45 {mfa, {rabbit_alarm, start, []}},
46 {requires, pre_boot},
47 {enables, external_infrastructure}]}).
48
4249 -rabbit_boot_step({database,
4350 [{mfa, {rabbit_mnesia, init, []}},
4451 {requires, file_handle_cache},
5360 -rabbit_boot_step({file_handle_cache,
5461 [{description, "file handle cache server"},
5562 {mfa, {rabbit, start_fhc, []}},
56 {requires, pre_boot},
63 %% FHC needs memory monitor to be running
64 {requires, rabbit_alarm},
5765 {enables, worker_pool}]}).
5866
5967 -rabbit_boot_step({worker_pool,
8391 -rabbit_boot_step({kernel_ready,
8492 [{description, "kernel ready"},
8593 {requires, external_infrastructure}]}).
86
87 -rabbit_boot_step({rabbit_alarm,
88 [{description, "alarm handler"},
89 {mfa, {rabbit_alarm, start, []}},
90 {requires, kernel_ready},
91 {enables, core_initialized}]}).
9294
9395 -rabbit_boot_step({rabbit_memory_monitor,
9496 [{description, "memory monitor"},
882884 %% We don't want this in fhc since it references rabbit stuff. And we can't put
883885 %% this in the bootstep directly.
884886 start_fhc() ->
885 rabbit_sup:start_restartable_child(
887 ok = rabbit_sup:start_restartable_child(
886888 file_handle_cache,
887 [fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]).
889 [fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]),
890 ensure_working_fhc().
891
892 ensure_working_fhc() ->
893 %% To test the file handle cache, we simply read a file we know it
894 %% exists (Erlang kernel's .app file).
895 %%
896 %% To avoid any pollution of the application process' dictionary by
897 %% file_handle_cache, we spawn a separate process.
898 Parent = self(),
899 TestFun = fun() ->
900 Filename = filename:join(code:lib_dir(kernel, ebin), "kernel.app"),
901 {ok, Fd} = file_handle_cache:open(Filename, [raw, binary, read], []),
902 {ok, _} = file_handle_cache:read(Fd, 1),
903 ok = file_handle_cache:close(Fd),
904 Parent ! fhc_ok
905 end,
906 TestPid = spawn_link(TestFun),
907 %% Because we are waiting for the test fun, abuse the
908 %% 'mnesia_table_loading_timeout' parameter to find a sane timeout
909 %% value.
910 Timeout = rabbit_table:wait_timeout(),
911 receive
912 fhc_ok -> ok;
913 {'EXIT', TestPid, Exception} -> throw({ensure_working_fhc, Exception})
914 after Timeout ->
915 throw({ensure_working_fhc, {timeout, TestPid}})
916 end.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_access_control).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_alarm).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_amqqueue).
781781 fun () ->
782782 Qs = mnesia:match_object(rabbit_queue,
783783 #amqqueue{_ = '_'}, write),
784 [case lists:member(Node, RSs) of
785 true -> RSs1 = RSs -- [Node],
786 store_queue(
787 Q#amqqueue{recoverable_slaves = RSs1});
788 false -> ok
789 end || #amqqueue{recoverable_slaves = RSs} = Q <- Qs],
784 [maybe_clear_recoverable_node(Node, Q) || Q <- Qs],
790785 ok
791786 end).
787
788 maybe_clear_recoverable_node(Node,
789 #amqqueue{sync_slave_pids = SPids,
790 recoverable_slaves = RSs} = Q) ->
791 case lists:member(Node, RSs) of
792 true ->
793 %% There is a race with
794 %% rabbit_mirror_queue_slave:record_synchronised/1 called
795 %% by the incoming slave node and this function, called
796 %% by the master node. If this function is executed after
797 %% record_synchronised/1, the node is erroneously removed
798 %% from the recoverable slaves list.
799 %%
800 %% We check if the slave node's queue PID is alive. If it is
801 %% the case, then this function is executed after. In this
802 %% situation, we don't touch the queue record, it is already
803 %% correct.
804 DoClearNode =
805 case [SP || SP <- SPids, node(SP) =:= Node] of
806 [SPid] -> not rabbit_misc:is_process_alive(SPid);
807 _ -> true
808 end,
809 if
810 DoClearNode -> RSs1 = RSs -- [Node],
811 store_queue(
812 Q#amqqueue{recoverable_slaves = RSs1});
813 true -> ok
814 end;
815 false ->
816 ok
817 end.
792818
793819 on_node_down(Node) ->
794820 rabbit_misc:execute_mnesia_tx_with_tail(
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_amqqueue_process).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_amqqueue_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_amqqueue_sup_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_dummy).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_backend_internal).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_mechanism).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_mechanism_amqplain).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_mechanism_cr_demo).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_auth_mechanism_plain).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_authn_backend).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_authz_backend).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_autoheal).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_backing_queue).
251251
252252 behaviour_info(callbacks) ->
253253 [{start, 1}, {stop, 0}, {init, 3}, {terminate, 2},
254 {delete_and_terminate, 2}, {purge, 1}, {purge_acks, 1}, {publish, 6},
254 {delete_and_terminate, 2}, {delete_crashed, 1}, {purge, 1},
255 {purge_acks, 1}, {publish, 6},
255256 {publish_delivered, 5}, {discard, 4}, {drain_confirmed, 1},
256 {dropwhile, 2}, {fetchwhile, 4},
257 {fetch, 2}, {ack, 2}, {requeue, 2}, {ackfold, 4}, {fold, 3}, {len, 1},
257 {dropwhile, 2}, {fetchwhile, 4}, {fetch, 2},
258 {drop, 2}, {ack, 2}, {requeue, 2}, {ackfold, 4}, {fold, 3}, {len, 1},
258259 {is_empty, 1}, {depth, 1}, {set_ram_duration_target, 2},
259260 {ram_duration, 1}, {needs_timeout, 1}, {timeout, 1},
260261 {handle_pre_hibernate, 1}, {resume, 1}, {msg_rates, 1},
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_basic).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_binary_generator).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_binary_parser).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_binding).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_channel).
3939 queue_consumers, delivering_queues,
4040 queue_collector_pid, stats_timer, confirm_enabled, publish_seqno,
4141 unconfirmed, confirmed, mandatory, capabilities, trace_state,
42 consumer_prefetch, reply_consumer}).
42 consumer_prefetch, reply_consumer,
43 %% flow | noflow, see rabbitmq-server#114
44 delivery_flow}).
4345
4446 -define(MAX_PERMISSION_CACHE_SIZE, 12).
4547
234236 process_flag(trap_exit, true),
235237 ?store_proc_name({ConnName, Channel}),
236238 ok = pg_local:join(rabbit_channels, self()),
239 Flow = case rabbit_misc:get_env(rabbit, mirroring_flow_control, true) of
240 true -> flow;
241 false -> noflow
242 end,
237243 State = #ch{state = starting,
238244 protocol = Protocol,
239245 channel = Channel,
262268 capabilities = Capabilities,
263269 trace_state = rabbit_trace:init(VHost),
264270 consumer_prefetch = 0,
265 reply_consumer = none},
271 reply_consumer = none,
272 delivery_flow = Flow},
266273 State1 = rabbit_event:init_stats_timer(State, #ch.stats_timer),
267274 rabbit_event:notify(channel_created, infos(?CREATION_EVENT_KEYS, State1)),
268275 rabbit_event:if_enabled(State1, #ch.stats_timer,
769776 confirm_enabled = ConfirmEnabled,
770777 trace_state = TraceState,
771778 user = #user{username = Username},
772 conn_name = ConnName}) ->
779 conn_name = ConnName,
780 delivery_flow = Flow}) ->
773781 check_msg_size(Content),
774782 ExchangeName = rabbit_misc:r(VHostPath, exchange, ExchangeNameBin),
775783 check_write_permitted(ExchangeName, State),
796804 QNames = rabbit_exchange:route(Exchange, Delivery),
797805 rabbit_trace:tap_in(Message, QNames, ConnName, ChannelNum,
798806 Username, TraceState),
799 DQ = {Delivery#delivery{flow = flow}, QNames},
807 DQ = {Delivery#delivery{flow = Flow}, QNames},
800808 {noreply, case Tx of
801809 none -> deliver_to_queues(DQ, State1);
802810 {Msgs, Acks} -> Msgs1 = queue:in(DQ, Msgs),
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% Since the AMQP methods used here are queue related,
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_channel_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_channel_sup_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_cli).
1717 -include("rabbit_cli.hrl").
1818
1919 -export([main/3, start_distribution/0, start_distribution/1,
20 parse_arguments/4, rpc_call/4]).
20 parse_arguments/4, rpc_call/4, rpc_call/5]).
2121
2222 %%----------------------------------------------------------------------------
2323
9393 print_error("~p", [Reason]),
9494 rabbit_misc:quit(2);
9595 {badrpc, Reason} ->
96 print_error("unable to connect to node ~w: ~w", [Node, Reason]),
97 print_badrpc_diagnostics([Node]),
96 case Reason of
97 timeout ->
98 print_error("operation ~w on node ~w timed out", [Command, Node]);
99 _ ->
100 print_error("unable to connect to node ~w: ~w", [Node, Reason]),
101 print_badrpc_diagnostics([Node])
102 end,
98103 rabbit_misc:quit(2);
99104 {badrpc_multi, Reason, Nodes} ->
100105 print_error("unable to connect to nodes ~p: ~w", [Nodes, Reason]),
209214 %% a timeout unless we set our ticktime to be the same. So let's do
210215 %% that.
211216 rpc_call(Node, Mod, Fun, Args) ->
212 case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of
217 rpc_call(Node, Mod, Fun, Args, ?RPC_TIMEOUT).
218
219 rpc_call(Node, Mod, Fun, Args, Timeout) ->
220 case rpc:call(Node, net_kernel, get_net_ticktime, [], Timeout) of
213221 {badrpc, _} = E -> E;
214222 Time -> net_kernel:set_net_ticktime(Time, 0),
215 rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT)
216 end.
223 rpc:call(Node, Mod, Fun, Args, Timeout)
224 end.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_client_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_command_assembler).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_connection_helper_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_connection_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_control_main).
1818 -include("rabbit_cli.hrl").
1919
2020 -export([start/0, stop/0, parse_arguments/2, action/5,
21 sync_queue/1, cancel_sync_queue/1, become/1]).
22
23 -import(rabbit_cli, [rpc_call/4]).
21 sync_queue/1, cancel_sync_queue/1, become/1,
22 purge_queue/1]).
23
24 -import(rabbit_cli, [rpc_call/4, rpc_call/5]).
2425
2526 -define(EXTERNAL_CHECK_INTERVAL, 1000).
2627
27 -define(GLOBAL_DEFS(Node), [?QUIET_DEF, ?NODE_DEF(Node)]).
28 -define(GLOBAL_DEFS(Node), [?QUIET_DEF, ?NODE_DEF(Node), ?TIMEOUT_DEF]).
2829
2930 -define(COMMANDS,
3031 [stop,
4445 cluster_status,
4546 {sync_queue, [?VHOST_DEF]},
4647 {cancel_sync_queue, [?VHOST_DEF]},
48 {purge_queue, [?VHOST_DEF]},
4749
4850 add_user,
4951 delete_user,
107109 forget_cluster_node, rename_cluster_node, cluster_status, status,
108110 environment, eval, force_boot]).
109111
112 -define(COMMANDS_WITH_TIMEOUT,
113 [list_user_permissions, list_policies, list_queues, list_exchanges,
114 list_bindings, list_connections, list_channels, list_consumers,
115 list_vhosts, list_parameters,
116 purge_queue]).
117
110118 %%----------------------------------------------------------------------------
111119
112120 -ifdef(use_specs).
116124 -spec(action/5 ::
117125 (atom(), node(), [string()], [{string(), any()}],
118126 fun ((string(), [any()]) -> 'ok'))
127 -> 'ok').
128
129 -spec(action/6 ::
130 (atom(), node(), [string()], [{string(), any()}],
131 fun ((string(), [any()]) -> 'ok'), timeout())
119132 -> 'ok').
120133
121134 -endif.
135148 io:format(Format ++ " ...~n", Args1)
136149 end
137150 end,
138 do_action(Command, Node, Args, Opts, Inform)
151 try
152 T = case get_timeout(Opts) of
153 {ok, Timeout} ->
154 Timeout;
155 {error, _} ->
156 %% since this is an error with user input, ignore the quiet
157 %% setting
158 io:format("Failed to parse provided timeout value, using ~s~n", [?RPC_TIMEOUT]),
159 ?RPC_TIMEOUT
160 end,
161 do_action(Command, Node, Args, Opts, Inform, T)
162 catch _:E -> E
163 end
139164 end, rabbit_ctl_usage).
140165
141166 parse_arguments(CmdLine, NodeStr) ->
159184 end,
160185 io:nl().
161186
187 get_timeout(Opts) ->
188 parse_timeout(proplists:get_value(?TIMEOUT_OPT, Opts, ?RPC_TIMEOUT)).
189
190 parse_number(N) when is_list(N) ->
191 try list_to_integer(N) of
192 Val -> Val
193 catch error:badarg ->
194 %% could have been a float, give it
195 %% another shot
196 list_to_float(N)
197 end.
198
199 parse_timeout("infinity") ->
200 {ok, infinity};
201 parse_timeout(infinity) ->
202 {ok, infinity};
203 parse_timeout(N) when is_list(N) ->
204 try parse_number(N) of
205 M ->
206 Y = case M >= 0 of
207 true -> round(M) * 1000;
208 false -> ?RPC_TIMEOUT
209 end,
210 {ok, Y}
211 catch error:badarg ->
212 {error, infinity}
213 end;
214 parse_timeout(N) ->
215 {ok, N}.
216
217 announce_timeout(infinity, _Inform) ->
218 %% no-op
219 ok;
220 announce_timeout(Timeout, Inform) when is_number(Timeout) ->
221 Inform("Timeout: ~w seconds", [Timeout/1000]),
222 ok.
223
162224 stop() ->
163225 ok.
164226
165227 %%----------------------------------------------------------------------------
166228
167 do_action(Command, Node, Args, Opts, Inform) ->
229 do_action(Command, Node, Args, Opts, Inform, Timeout) ->
168230 case lists:member(Command, ?COMMANDS_NOT_REQUIRING_APP) of
169 false -> case ensure_app_running(Node) of
170 ok -> action(Command, Node, Args, Opts, Inform);
171 E -> E
172 end;
173 true -> action(Command, Node, Args, Opts, Inform)
231 false ->
232 case ensure_app_running(Node) of
233 ok ->
234 case lists:member(Command, ?COMMANDS_WITH_TIMEOUT) of
235 true ->
236 announce_timeout(Timeout, Inform),
237 action(Command, Node, Args, Opts, Inform, Timeout);
238 false ->
239 action(Command, Node, Args, Opts, Inform)
240 end;
241 E -> E
242 end;
243 true ->
244 action(Command, Node, Args, Opts, Inform)
174245 end.
175246
176247 action(stop, Node, Args, _Opts, Inform) ->
312383 rpc_call(Node, rabbit_auth_backend_internal, set_tags,
313384 [list_to_binary(Username), Tags]);
314385
315 action(list_users, Node, [], _Opts, Inform) ->
316 Inform("Listing users", []),
317 display_info_list(
318 call(Node, {rabbit_auth_backend_internal, list_users, []}),
319 rabbit_auth_backend_internal:user_info_keys());
320
321386 action(add_vhost, Node, Args = [_VHostPath], _Opts, Inform) ->
322387 Inform("Creating vhost \"~s\"", Args),
323388 call(Node, {rabbit_vhost, add, Args});
325390 action(delete_vhost, Node, Args = [_VHostPath], _Opts, Inform) ->
326391 Inform("Deleting vhost \"~s\"", Args),
327392 call(Node, {rabbit_vhost, delete, Args});
328
329 action(list_vhosts, Node, Args, _Opts, Inform) ->
330 Inform("Listing vhosts", []),
331 ArgAtoms = default_if_empty(Args, [name]),
332 display_info_list(call(Node, {rabbit_vhost, info_all, []}), ArgAtoms);
333
334 action(list_user_permissions, Node, Args = [_Username], _Opts, Inform) ->
335 Inform("Listing permissions for user ~p", Args),
336 display_info_list(call(Node, {rabbit_auth_backend_internal,
337 list_user_permissions, Args}),
338 rabbit_auth_backend_internal:user_perms_info_keys());
339
340 action(list_queues, Node, Args, Opts, Inform) ->
341 Inform("Listing queues", []),
342 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
343 ArgAtoms = default_if_empty(Args, [name, messages]),
344 display_info_list(rpc_call(Node, rabbit_amqqueue, info_all,
345 [VHostArg, ArgAtoms]),
346 ArgAtoms);
347
348 action(list_exchanges, Node, Args, Opts, Inform) ->
349 Inform("Listing exchanges", []),
350 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
351 ArgAtoms = default_if_empty(Args, [name, type]),
352 display_info_list(rpc_call(Node, rabbit_exchange, info_all,
353 [VHostArg, ArgAtoms]),
354 ArgAtoms);
355
356 action(list_bindings, Node, Args, Opts, Inform) ->
357 Inform("Listing bindings", []),
358 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
359 ArgAtoms = default_if_empty(Args, [source_name, source_kind,
360 destination_name, destination_kind,
361 routing_key, arguments]),
362 display_info_list(rpc_call(Node, rabbit_binding, info_all,
363 [VHostArg, ArgAtoms]),
364 ArgAtoms);
365
366 action(list_connections, Node, Args, _Opts, Inform) ->
367 Inform("Listing connections", []),
368 ArgAtoms = default_if_empty(Args, [user, peer_host, peer_port, state]),
369 display_info_list(rpc_call(Node, rabbit_networking, connection_info_all,
370 [ArgAtoms]),
371 ArgAtoms);
372
373 action(list_channels, Node, Args, _Opts, Inform) ->
374 Inform("Listing channels", []),
375 ArgAtoms = default_if_empty(Args, [pid, user, consumer_count,
376 messages_unacknowledged]),
377 display_info_list(rpc_call(Node, rabbit_channel, info_all, [ArgAtoms]),
378 ArgAtoms);
379
380 action(list_consumers, Node, _Args, Opts, Inform) ->
381 Inform("Listing consumers", []),
382 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
383 display_info_list(rpc_call(Node, rabbit_amqqueue, consumers_all, [VHostArg]),
384 rabbit_amqqueue:consumer_info_keys());
385393
386394 action(trace_on, Node, [], Opts, Inform) ->
387395 VHost = proplists:get_value(?VHOST_OPT, Opts),
415423 call(Node, {rabbit_auth_backend_internal, clear_permissions,
416424 [Username, VHost]});
417425
418 action(list_permissions, Node, [], Opts, Inform) ->
419 VHost = proplists:get_value(?VHOST_OPT, Opts),
420 Inform("Listing permissions in vhost \"~s\"", [VHost]),
421 display_info_list(call(Node, {rabbit_auth_backend_internal,
422 list_vhost_permissions, [VHost]}),
423 rabbit_auth_backend_internal:vhost_perms_info_keys());
424
425426 action(set_parameter, Node, [Component, Key, Value], Opts, Inform) ->
426427 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
427428 Inform("Setting runtime parameter ~p for component ~p to ~p",
436437 rpc_call(Node, rabbit_runtime_parameters, clear, [VHostArg,
437438 list_to_binary(Component),
438439 list_to_binary(Key)]);
439
440 action(list_parameters, Node, [], Opts, Inform) ->
441 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
442 Inform("Listing runtime parameters", []),
443 display_info_list(
444 rpc_call(Node, rabbit_runtime_parameters, list_formatted, [VHostArg]),
445 rabbit_runtime_parameters:info_keys());
446440
447441 action(set_policy, Node, [Key, Pattern, Defn], Opts, Inform) ->
448442 Msg = "Setting policy ~p for pattern ~p to ~p with priority ~p",
458452 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
459453 Inform("Clearing policy ~p", [Key]),
460454 rpc_call(Node, rabbit_policy, delete, [VHostArg, list_to_binary(Key)]);
461
462 action(list_policies, Node, [], Opts, Inform) ->
463 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
464 Inform("Listing policies", []),
465 display_info_list(rpc_call(Node, rabbit_policy, list_formatted, [VHostArg]),
466 rabbit_policy:info_keys());
467455
468456 action(report, Node, _Args, _Opts, Inform) ->
469457 Inform("Reporting server status on ~p~n~n", [erlang:universaltime()]),
492480 end;
493481 {error, E, _} ->
494482 {error_string, format_parse_error(E)}
495 end.
483 end;
484
485 action(Command, Node, Args, Opts, Inform) ->
486 %% For backward compatibility, run commands accepting a timeout with
487 %% the default timeout.
488 action(Command, Node, Args, Opts, Inform, ?RPC_TIMEOUT).
489
490 action(purge_queue, _Node, [], _Opts, _Inform, _Timeout) ->
491 {error, "purge_queue takes queue name as an argument"};
492
493 action(purge_queue, Node, [Q], Opts, Inform, Timeout) ->
494 VHost = proplists:get_value(?VHOST_OPT, Opts),
495 QRes = rabbit_misc:r(list_to_binary(VHost), queue, list_to_binary(Q)),
496 Inform("Purging ~s", [rabbit_misc:rs(QRes)]),
497 rpc_call(Node, rabbit_control_main, purge_queue, [QRes], Timeout);
498
499 action(list_users, Node, [], _Opts, Inform, Timeout) ->
500 Inform("Listing users", []),
501 display_info_list(
502 call(Node, {rabbit_auth_backend_internal, list_users, []}, Timeout),
503 rabbit_auth_backend_internal:user_info_keys());
504
505 action(list_permissions, Node, [], Opts, Inform, Timeout) ->
506 VHost = proplists:get_value(?VHOST_OPT, Opts),
507 Inform("Listing permissions in vhost \"~s\"", [VHost]),
508 display_info_list(call(Node, {rabbit_auth_backend_internal,
509 list_vhost_permissions, [VHost]}, Timeout),
510 rabbit_auth_backend_internal:vhost_perms_info_keys());
511
512 action(list_parameters, Node, [], Opts, Inform, Timeout) ->
513 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
514 Inform("Listing runtime parameters", []),
515 display_info_list(
516 rpc_call(Node, rabbit_runtime_parameters, list_formatted, [VHostArg],
517 Timeout),
518 rabbit_runtime_parameters:info_keys());
519
520 action(list_policies, Node, [], Opts, Inform, Timeout) ->
521 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
522 Inform("Listing policies", []),
523 display_info_list(rpc_call(Node, rabbit_policy, list_formatted, [VHostArg],
524 Timeout),
525 rabbit_policy:info_keys());
526
527 action(list_vhosts, Node, Args, _Opts, Inform, Timeout) ->
528 Inform("Listing vhosts", []),
529 ArgAtoms = default_if_empty(Args, [name]),
530 display_info_list(call(Node, {rabbit_vhost, info_all, []}, Timeout),
531 ArgAtoms);
532
533 action(list_user_permissions, _Node, _Args = [], _Opts, _Inform, _Timeout) ->
534 {error_string,
535 "list_user_permissions expects a username argument, but none provided."};
536 action(list_user_permissions, Node, Args = [_Username], _Opts, Inform, Timeout) ->
537 Inform("Listing permissions for user ~p", Args),
538 display_info_list(call(Node, {rabbit_auth_backend_internal,
539 list_user_permissions, Args}, Timeout),
540 rabbit_auth_backend_internal:user_perms_info_keys());
541
542 action(list_queues, Node, Args, Opts, Inform, Timeout) ->
543 Inform("Listing queues", []),
544 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
545 ArgAtoms = default_if_empty(Args, [name, messages]),
546 display_info_list(rpc_call(Node, rabbit_amqqueue, info_all,
547 [VHostArg, ArgAtoms], Timeout),
548 ArgAtoms);
549
550 action(list_exchanges, Node, Args, Opts, Inform, Timeout) ->
551 Inform("Listing exchanges", []),
552 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
553 ArgAtoms = default_if_empty(Args, [name, type]),
554 display_info_list(rpc_call(Node, rabbit_exchange, info_all,
555 [VHostArg, ArgAtoms], Timeout),
556 ArgAtoms);
557
558 action(list_bindings, Node, Args, Opts, Inform, Timeout) ->
559 Inform("Listing bindings", []),
560 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
561 ArgAtoms = default_if_empty(Args, [source_name, source_kind,
562 destination_name, destination_kind,
563 routing_key, arguments]),
564 display_info_list(rpc_call(Node, rabbit_binding, info_all,
565 [VHostArg, ArgAtoms], Timeout),
566 ArgAtoms);
567
568 action(list_connections, Node, Args, _Opts, Inform, Timeout) ->
569 Inform("Listing connections", []),
570 ArgAtoms = default_if_empty(Args, [user, peer_host, peer_port, state]),
571 display_info_list(rpc_call(Node, rabbit_networking, connection_info_all,
572 [ArgAtoms], Timeout),
573 ArgAtoms);
574
575 action(list_channels, Node, Args, _Opts, Inform, Timeout) ->
576 Inform("Listing channels", []),
577 ArgAtoms = default_if_empty(Args, [pid, user, consumer_count,
578 messages_unacknowledged]),
579 display_info_list(rpc_call(Node, rabbit_channel, info_all, [ArgAtoms],
580 Timeout),
581 ArgAtoms);
582
583 action(list_consumers, Node, _Args, Opts, Inform, Timeout) ->
584 Inform("Listing consumers", []),
585 VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
586 display_info_list(rpc_call(Node, rabbit_amqqueue, consumers_all, [VHostArg],
587 Timeout),
588 rabbit_amqqueue:consumer_info_keys()).
589
496590
497591 format_parse_error({_Line, Mod, Err}) -> lists:flatten(Mod:format_error(Err)).
498592
504598 rabbit_amqqueue:with(
505599 Q, fun(#amqqueue{pid = QPid}) ->
506600 rabbit_amqqueue:cancel_sync_mirrors(QPid)
601 end).
602
603 purge_queue(Q) ->
604 rabbit_amqqueue:with(
605 Q, fun(Q1) ->
606 rabbit_amqqueue:purge(Q1),
607 ok
507608 end).
508609
509610 %%----------------------------------------------------------------------------
649750 call(Node, {Mod, Fun, Args}) ->
650751 rpc_call(Node, Mod, Fun, lists:map(fun list_to_binary_utf8/1, Args)).
651752
753 call(Node, {Mod, Fun, Args}, Timeout) ->
754 rpc_call(Node, Mod, Fun, lists:map(fun list_to_binary_utf8/1, Args), Timeout).
755
652756 list_to_binary_utf8(L) ->
653757 B = list_to_binary(L),
654758 case rabbit_binary_parser:validate_utf8(B) of
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_dead_letter).
7777 content = Content2}.
7878
7979
80 x_death_event_key(Info, Key, KeyType) ->
80 x_death_event_key(Info, Key) ->
8181 case lists:keysearch(Key, 1, Info) of
82 false -> undefined;
83 {value, {Key, KeyType, Val}} -> Val
84 end.
82 false -> undefined;
83 {value, {Key, _KeyType, Val}} -> Val
84 end.
85
86 maybe_append_to_event_group(Table, _Key, _SeenKeys, []) ->
87 [Table];
88 maybe_append_to_event_group(Table, {_Queue, _Reason} = Key, SeenKeys, Acc) ->
89 case sets:is_element(Key, SeenKeys) of
90 true -> Acc;
91 false -> [Table | Acc]
92 end.
93
94 group_by_queue_and_reason([]) ->
95 [];
96 group_by_queue_and_reason([Table]) ->
97 [Table];
98 group_by_queue_and_reason(Tables) ->
99 {_, Grouped} =
100 lists:foldl(
101 fun ({table, Info}, {SeenKeys, Acc}) ->
102 Q = x_death_event_key(Info, <<"queue">>),
103 R = x_death_event_key(Info, <<"reason">>),
104 Matcher = queue_and_reason_matcher(Q, R),
105 {Matches, _} = lists:partition(Matcher, Tables),
106 {Augmented, N} = case Matches of
107 [X] -> {X, 1};
108 [X|_] = Xs -> {X, length(Xs)}
109 end,
110 Key = {Q, R},
111 Acc1 = maybe_append_to_event_group(
112 ensure_xdeath_event_count(Augmented, N),
113 Key, SeenKeys, Acc),
114 {sets:add_element(Key, SeenKeys), Acc1}
115 end, {sets:new(), []}, Tables),
116 Grouped.
85117
86118 update_x_death_header(Info, Headers) ->
87 Q = x_death_event_key(Info, <<"queue">>, longstr),
88 R = x_death_event_key(Info, <<"reason">>, longstr),
119 Q = x_death_event_key(Info, <<"queue">>),
120 R = x_death_event_key(Info, <<"reason">>),
89121 case rabbit_basic:header(<<"x-death">>, Headers) of
90122 undefined ->
91 rabbit_basic:prepend_table_header(<<"x-death">>,
123 rabbit_basic:prepend_table_header(
124 <<"x-death">>,
92125 [{<<"count">>, long, 1} | Info], Headers);
93126 {<<"x-death">>, array, Tables} ->
127 %% group existing x-death headers in case we have some from
128 %% before rabbitmq-server#78
129 GroupedTables = group_by_queue_and_reason(Tables),
94130 {Matches, Others} = lists:partition(
95 fun ({table, Info0}) ->
96 x_death_event_key(Info0, <<"queue">>, longstr) =:= Q
97 andalso x_death_event_key(Info0, <<"reason">>, longstr) =:= R
98 end, Tables),
131 queue_and_reason_matcher(Q, R),
132 GroupedTables),
99133 Info1 = case Matches of
100134 [] ->
101135 [{<<"count">>, long, 1} | Info];
102136 [{table, M}] ->
103 case x_death_event_key(M, <<"count">>, long) of
104 undefined ->
105 [{<<"count">>, long, 1} | M];
106 N ->
107 lists:keyreplace(
108 <<"count">>, 1, M,
109 {<<"count">>, long, N + 1})
110 end
137 increment_xdeath_event_count(M)
111138 end,
112 rabbit_misc:set_table_value(Headers, <<"x-death">>, array,
139 rabbit_misc:set_table_value(
140 Headers, <<"x-death">>, array,
113141 [{table, rabbit_misc:sort_field_table(Info1)} | Others])
142 end.
143
144 ensure_xdeath_event_count({table, Info}, InitialVal) when InitialVal >= 1 ->
145 {table, ensure_xdeath_event_count(Info, InitialVal)};
146 ensure_xdeath_event_count(Info, InitialVal) when InitialVal >= 1 ->
147 case x_death_event_key(Info, <<"count">>) of
148 undefined ->
149 [{<<"count">>, long, InitialVal} | Info];
150 _ ->
151 Info
152 end.
153
154 increment_xdeath_event_count(Info) ->
155 case x_death_event_key(Info, <<"count">>) of
156 undefined ->
157 [{<<"count">>, long, 1} | Info];
158 N ->
159 lists:keyreplace(
160 <<"count">>, 1, Info,
161 {<<"count">>, long, N + 1})
162 end.
163
164 queue_and_reason_matcher(Q, R) ->
165 F = fun(Info) ->
166 x_death_event_key(Info, <<"queue">>) =:= Q
167 andalso x_death_event_key(Info, <<"reason">>) =:= R
168 end,
169 fun({table, Info}) ->
170 F(Info);
171 (Info) when is_list(Info) ->
172 F(Info)
114173 end.
115174
116175 per_msg_ttl_header(#'P_basic'{expiration = undefined}) ->
177236 true -> ok;
178237 undefined -> rabbit_log:warning(
179238 "Message dropped. Dead-letter queues cycle detected" ++
180 ": ~p~nThis cycle will NOT be reported again.~n",
239 ": ~p~nThis cycle will NOT be reported again.~n",
181240 [Queues]),
182241 put(Key, true)
183242 end.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_diagnostics).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_direct).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_disk_monitor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_epmd_monitor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_error_logger).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_error_logger_file_h).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_event).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_decorator).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_type).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_type_direct).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_type_fanout).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_type_headers).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_type_invalid).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_exchange_type_topic).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_file).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% TODO auto-generate
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_guid).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_heartbeat).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% The purpose of the limiter is to stem the flow of messages from
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_log).
8383 level(debug) -> 4;
8484 level(info) -> 3;
8585 level(warning) -> 2;
86 level(warn) -> 2;
8687 level(error) -> 1;
8788 level(none) -> 0.
8889
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616
2424 -behaviour(gen_server2).
2525
2626 -export([start_link/0, register/2, deregister/1,
27 report_ram_duration/2, stop/0, conserve_resources/3]).
27 report_ram_duration/2, stop/0, conserve_resources/3, memory_use/1]).
2828
2929 -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
3030 terminate/2, code_change/3]).
9090 gen_server2:cast(Pid, {disk_alarm, Conserve});
9191 conserve_resources(_Pid, _Source, _Conserve) ->
9292 ok.
93
94 memory_use(bytes) ->
95 MemoryLimit = vm_memory_monitor:get_memory_limit(),
96 {erlang:memory(total), case MemoryLimit > 0.0 of
97 true -> MemoryLimit;
98 false -> infinity
99 end};
100 memory_use(ratio) ->
101 MemoryLimit = vm_memory_monitor:get_memory_limit(),
102 case MemoryLimit > 0.0 of
103 true -> erlang:memory(total) / MemoryLimit;
104 false -> infinity
105 end.
93106
94107 %%----------------------------------------------------------------------------
95108 %% Gen_server callbacks
222235 queue_duration_count = Count}) ->
223236 {ok, LimitThreshold} =
224237 application:get_env(rabbit, vm_memory_high_watermark_paging_ratio),
225 MemoryLimit = vm_memory_monitor:get_memory_limit(),
226 MemoryRatio = case MemoryLimit > 0.0 of
227 true -> erlang:memory(total) / MemoryLimit;
228 false -> infinity
229 end,
238 MemoryRatio = memory_use(ratio),
230239 if MemoryRatio =:= infinity ->
231240 0.0;
232241 MemoryRatio < LimitThreshold orelse Count == 0 ->
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_coordinator).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_master).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_misc).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_mode).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_mode_all).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_mode_exactly).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_mode_nodes).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mirror_queue_slave).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_misc).
7171 -export([store_proc_name/1, store_proc_name/2]).
7272 -export([moving_average/4]).
7373 -export([now_to_ms/1]).
74 -export([get_env/3]).
7475
7576 %% Horrible macro to use in guards
7677 -define(IS_BENIGN_EXIT(R),
260261 -spec(now_to_ms/1 :: ({non_neg_integer(),
261262 non_neg_integer(),
262263 non_neg_integer()}) -> pos_integer()).
264 -spec(get_env/3 :: (atom(), atom(), term()) -> term()).
263265 -endif.
264266
265267 %%----------------------------------------------------------------------------
10951097 store_proc_name(Type, ProcName) -> store_proc_name({Type, ProcName}).
10961098 store_proc_name(TypeProcName) -> put(process_name, TypeProcName).
10971099
1100 %% application:get_env/3 is only available in R16B01 or later.
1101 get_env(Application, Key, Def) ->
1102 case application:get_env(Application, Key) of
1103 {ok, Val} -> Val;
1104 undefined -> Def
1105 end.
1106
10981107 moving_average(_Time, _HalfLife, Next, undefined) ->
10991108 Next;
11001109 %% We want the Weight to decrease as Time goes up (since Weight is the
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mnesia).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_mnesia_rename).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_msg_file).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_msg_store).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_msg_store_ets_index).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_msg_store_gc).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_msg_store_index).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_net).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_networking).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_node_monitor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_nodes).
136136 [{" * TCP connection succeeded but Erlang distribution "
137137 "failed~n"
138138 " * suggestion: hostname mismatch?~n"
139 " * suggestion: is the cookie set correctly?", []}];
139 " * suggestion: is the cookie set correctly?~n"
140 " * suggestion: is the Erlang distribution using TLS?", []}];
140141 {error, Reason} ->
141142 [{" * can't establish TCP connection, reason: ~s~n"
142143 " * suggestion: blocked by firewall?",
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_parameter_validation).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_plugins).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2011-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2011-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_plugins_main).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_policies).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_policy).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_policy_validator).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_prelaunch).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2010-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_prequeue).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_priority_queue).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_queue_collector).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_queue_consumers).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_queue_index).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_reader).
195195 log(error, "Error on AMQP connection ~p: ~s~n",
196196 [self(), rabbit_misc:format_inet_error(Reason)]);
197197 socket_error(Reason) ->
198 log(error, "Error on AMQP connection ~p:~n~p~n", [self(), Reason]).
198 Level =
199 case Reason of
200 {ssl_upgrade_error, closed} ->
201 %% The socket was closed while upgrading to SSL.
202 %% This is presumably a TCP healthcheck, so don't log
203 %% it unless specified otherwise.
204 debug;
205 _ ->
206 error
207 end,
208 log(Level, "Error on AMQP connection ~p:~n~p~n", [self(), Reason]).
199209
200210 inet_op(F) -> rabbit_misc:throw_on_error(inet_error, F).
201211
262272 handshake, 8)]}),
263273 log(info, "closing AMQP connection ~p (~s)~n", [self(), Name])
264274 catch
265 Ex -> log(case Ex of
266 connection_closed_with_no_data_received -> debug;
267 connection_closed_abruptly -> warning;
268 _ -> error
269 end, "closing AMQP connection ~p (~s):~n~p~n",
270 [self(), Name, Ex])
275 Ex ->
276 log_connection_exception(Name, Ex)
271277 after
272278 %% We don't call gen_tcp:close/1 here since it waits for
273279 %% pending output to be sent, which results in unnecessary
281287 rabbit_event:notify(connection_closed, [{pid, self()}])
282288 end,
283289 done.
290
291 log_connection_exception(Name, Ex) ->
292 Severity = case Ex of
293 connection_closed_with_no_data_received -> debug;
294 connection_closed_abruptly -> warning;
295 _ -> error
296 end,
297 log_connection_exception(Severity, Name, Ex).
298
299 log_connection_exception(Severity, Name, {heartbeat_timeout, TimeoutSec}) ->
300 %% Long line to avoid extra spaces and line breaks in log
301 log(Severity, "closing AMQP connection ~p (~s):~nMissed heartbeats from client, timeout: ~ps~n",
302 [self(), Name, TimeoutSec]);
303 log_connection_exception(Severity, Name, Ex) ->
304 log(Severity, "closing AMQP connection ~p (~s):~n~p~n",
305 [self(), Name, Ex]).
284306
285307 run({M, F, A}) ->
286308 try apply(M, F, A)
344366 State#v1{pending_recv = false});
345367 closed when State#v1.connection_state =:= closed ->
346368 ok;
369 closed when CS =:= pre_init andalso Buf =:= [] ->
370 stop(tcp_healthcheck, State);
347371 closed ->
348372 stop(closed, State);
349373 {error, Reason} ->
358382 end
359383 end.
360384
361 stop(closed, #v1{connection_state = pre_init} = State) ->
385 stop(tcp_healthcheck, State) ->
362386 %% The connection was closed before any packet was received. It's
363387 %% probably a load-balancer healthcheck: don't consider this a
364388 %% failure.
420444 throw({handshake_timeout, State#v1.callback});
421445 handle_other(heartbeat_timeout, State = #v1{connection_state = closed}) ->
422446 State;
423 handle_other(heartbeat_timeout, State = #v1{connection_state = S}) ->
447 handle_other(heartbeat_timeout,
448 State = #v1{connection = #connection{timeout_sec = T}}) ->
424449 maybe_emit_stats(State),
425 throw({heartbeat_timeout, S});
450 throw({heartbeat_timeout, T});
426451 handle_other({'$gen_call', From, {shutdown, Explanation}}, State) ->
427452 {ForceTermination, NewState} = terminate(Explanation, State),
428453 gen_server:reply(From, ok),
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% We use a gen_server simply so that during the terminate/2 call
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_registry).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_restartable_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_router).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_runtime_parameter).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_runtime_parameters).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_sasl_report_file_h).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_ssl).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_table).
1717
1818 -export([create/0, create_local_copy/1, wait_for_replicated/0, wait/1,
1919 force_load/0, is_present/0, is_empty/0, needs_default_data/0,
20 check_schema_integrity/0, clear_ram_only_tables/0]).
20 check_schema_integrity/0, clear_ram_only_tables/0, wait_timeout/0]).
2121
2222 -include("rabbit.hrl").
2323
2929 -spec(create_local_copy/1 :: ('disc' | 'ram') -> 'ok').
3030 -spec(wait_for_replicated/0 :: () -> 'ok').
3131 -spec(wait/1 :: ([atom()]) -> 'ok').
32 -spec(wait_timeout/0 :: () -> non_neg_integer() | infinity).
3233 -spec(force_load/0 :: () -> 'ok').
3334 -spec(is_present/0 :: () -> boolean()).
3435 -spec(is_empty/0 :: () -> boolean()).
7273 wait(TableNames) ->
7374 %% We might be in ctl here for offline ops, in which case we can't
7475 %% get_env() for the rabbit app.
75 Timeout = case application:get_env(rabbit, mnesia_table_loading_timeout) of
76 {ok, T} -> T;
77 undefined -> 30000
78 end,
76 Timeout = wait_timeout(),
7977 case mnesia:wait_for_tables(TableNames, Timeout) of
8078 ok ->
8179 ok;
8381 throw({error, {timeout_waiting_for_tables, BadTabs}});
8482 {error, Reason} ->
8583 throw({error, {failed_waiting_for_tables, Reason}})
84 end.
85
86 wait_timeout() ->
87 case application:get_env(rabbit, mnesia_table_loading_timeout) of
88 {ok, T} -> T;
89 undefined -> 30000
8690 end.
8791
8892 force_load() -> [mnesia:force_load_table(T) || T <- names()], ok.
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_trace).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_types).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_upgrade).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_upgrade_functions).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_variable_queue).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_version).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_vhost).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_vm).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(rabbit_writer).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% Invoke callbacks on startup and termination.
136136 -record(state, {name,
137137 strategy :: strategy(),
138138 children = [] :: [child_rec()],
139 dynamics :: ?DICT:?DICT() | ?SET:?SET(),
139 dynamics :: ?DICT:?DICT() | ?SETS:?SET(),
140140 intensity :: non_neg_integer(),
141141 period :: pos_integer(),
142142 restarts = [],
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(tcp_acceptor).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(tcp_acceptor_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(tcp_listener).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(tcp_listener_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(truncate).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 %% In practice Erlang shouldn't be allowed to grow to more than a half
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(worker_pool).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(worker_pool_sup).
1010 %% The Original Code is RabbitMQ.
1111 %%
1212 %% The Initial Developer of the Original Code is GoPivotal, Inc.
13 %% Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
13 %% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
1414 %%
1515
1616 -module(worker_pool_worker).
0 VERSION?=3.5.1
0 VERSION?=3.5.4