Reputation: 21
I'm developing a custom RabbitMQ plugin based on the example from the rabbitmq-metronome repository. Despite enabling and activating the plugin, I'm unable to see any logs from it either in the console or in the specified log file. Here are the steps I've taken:
docker run -d --hostname my-rabbit --name ecomm-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:management
rebar3 compile
rebar3 archive
docker cp C:\Work\Erlang\my_plugin\_build\default\plugins\my_plugin-0.1.0.ez ecomm-rabbit:/opt/rabbitmq/plugins/
docker exec -it ecomm-rabbit rabbitmq-plugins enable my_plugin
# rabbitmq-plugins list
Listing plugins with pattern ".*" ...
Configured: E = explicitly enabled; e = implicitly enabled
| Status: * = running on rabbit@my-rabbit
|/
[E*] my_plugin 0.1.0
[ ] rabbitmq_amqp1_0 4.0.6
[ ] rabbitmq_auth_backend_cache 4.0.6
[ ] rabbitmq_auth_backend_http 4.0.6
etc
{erl_opts, [debug_info]}.
{deps, [
{amqp_client, "4.0.3"},
{rabbit_common, "4.0.3"}
]}.
{plugins, [
{rebar3_archive_plugin, {git, "https://github.com/deadtrickster/rebar3_archive_plugin.git", {branch, "master"}}}
]}.
{plugins_dir, "ebin"}.
{rabbitmq_plugins, [
{my_plugin, []}
]}.
-module(my_plugin).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
rabbit_log:info("~~ hello world ~~"),
my_plugin_sup:start_link().
stop(_State) ->
ok.
{application, my_plugin,
[
{description, "My First RabbitMQ Plugin"},
{vsn, "0.1.0"},
{modules, [my_plugin, my_plugin_sup, my_plugin_worker]},
{registered, []},
{applications, [kernel, stdlib, rabbit, amqp_client]},
{env, [{exchange, <<"easy_net_q_rpc">>}]}
]}.
-module(my_plugin_worker).
-behaviour(gen_server).
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
init([]) ->
rabbit_log:info("My Plugin Worker Started!"),
{ok, #{}}.
handle_call(_Request, _From, State) ->
{reply, ok, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
rabbit_log:info("My Plugin Worker Terminated!"),
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
-module(my_plugin_sup).
-behaviour(supervisor).
-export([start_link/0, init/1]).
start_link() ->
rabbit_log:info("~~ SUPERVISOR STARTING ~~"),
supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = []).
init([]) ->
rabbit_log:info("~~ SUPERVISOR INIT ~~"),
{ok, {{one_for_one, 3, 10},
[{my_plugin_worker,
{my_plugin_worker, start_link, []},
permanent,
10000,
worker,
[my_plugin_worker]}
]}}.
Despite these steps, no logs appear from my plugin. I've checked the permissions and ensured that the plugin is enabled and running. It looks like the plugin is not enough to be enabled or it needs additional options/parameters. Any suggestions would be greatly appreciated.
Thank you.
Upvotes: 0
Views: 74