In case of non-generated names it's enough to call #'queue.declare'
to get newly created queue or existing one with given name. However, when using auto-generated names (beginning with amq.gen-
prefix) it's not as trivial. First of all, amq.
is restricted prefix, so there is no way to call #'queue.declare'{queue=<<"amq.gen-xxx">>}
.
I also tried to play with passive=true
option and although I may pass restricted name, I get an exit error when queue does not exists. Following is error report:
** Handler sse_handler terminating in init/3
for the reason exit:{{shutdown,
{server_initiated_close,404,
<<"NOT_FOUND - no queue 'amq.gen-wzPK0nIBPzr-dwtZ5Jy58V' in vhost '/'">>}},
{gen_server,call,
[<0.62.0>,
{call,
{'queue.declare',0,
<<"amq.gen-wzPK0nIBPzr-dwtZ5Jy58V">>,
true,false,false,false,false,[]},
none,<0.269.0>},
infinity]}}
Is there any way to solve this problem?
EDIT: Here is a short story behind this question. Disclaimer: I'm erlang newbie, so maybe there is better way to make it working :)
I have a gen_server based application holding SSE (server-side events) connections with web browsers. Each connection is bound to rabbitmq queue. SSE connection when broken, automatically tries to reconnect after given timeout - this is something that web browser supports out of the box. To reuse previously created queue I'm trying to check if queue of given name (taken from request cookie) already exists. It's all done in init
callback.
rabbitmqctl
command can list queues. Is this help? – halfelfamq.
prefixes. Thanks! – Michal