RabbitMQ exchanges cleanup when subscriber is removed

2,210 views
Skip to first unread message

Guillaume Schuermans

unread,
Oct 23, 2013, 4:18:33 AM10/23/13
to masstrans...@googlegroups.com
Hello,

I might be wrong or might be doing some wrong, but the rabbitmq exchange for a message remains existing when there is no active subscription anymore.

Assume I have an event ProductOrdered.
This event is published from an api.
The billing system is subscribed to this event and will run its logic upon reception.
-> this creates an exchange in rabbitmq. Right?

Now, I when remove the ProductOrderedEventHandler which implements Consumes<ProductOrdered>.All from the billing system (just a windows service), the exchange isn't removed from RabbitMQ.

Am I missing something?

Kind regards,

Guillaume

Chris Patterson

unread,
Oct 23, 2013, 9:58:32 AM10/23/13
to masstrans...@googlegroups.com
Permanent subscriptions are not removed automatically, so the exchange will remain bound to the queue/exchange. If you remove a subscription from the system (due to ongoing changes, etc.), you will need to either create a script, use HareDu (a library for administering RabbitMQ from .NET), or manually remove the exchange binding so that published messages are no longer delivered to the queue.

In theory, a call could be added say at a certain point in time, the service is started and all extraneous exchange bindings should be removed, that's something that could fairly easily be written, but discovering the existing exchange bindings is actually very difficult without going through the management REST API.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/37939d93-85b1-4d83-8e57-645c65d8eff4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Otto Gebb

unread,
Dec 18, 2018, 11:47:31 AM12/18/18
to masstransit-discuss
Chris, has the situation with binding cleanup automation improved in the recent years? Maybe there are new tools or libraries for that?

Eric Piraux

unread,
Dec 18, 2018, 1:24:50 PM12/18/18
to masstrans...@googlegroups.com
I'm interested in sharing knowledge about that subject.

The answer is not trivial. I'd extend the question to Exchanges and Queues too.

Maybe working with a generated script based on a diff between the rabbit vhost definitions and the masstransit consumer configuration ?

Eric


Le mar. 18 déc. 2018 à 17:47, Otto Gebb <otto...@gmail.com> a écrit :
Chris, has the situation with binding cleanup automation improved in the recent years? Maybe there are new tools or libraries for that?

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Pavel Mihailov

unread,
Dec 20, 2018, 12:02:32 PM12/20/18
to masstransit-discuss
Hi,
What we have done is that we created a small tool that extracted all exchanges and queues names from RabbitMQ using HareDu. Then we compare the data with extract from "clean" env. and remove unused exchanges and queues (again using HareDu).

Eric Piraux

unread,
Dec 21, 2018, 1:56:47 AM12/21/18
to masstrans...@googlegroups.com
Hi,

Very interesting, I didn't know that HareDu lib.

And how do you define a "clean" environment ?
Is it for instance a clean deploy of your bus and letting it run a while on a blank vhost to let it create all exchanges/bindings/queues it needs ?

Eric


Le jeu. 20 déc. 2018 à 18:02, Pavel Mihailov <icera...@gmail.com> a écrit :
Hi,
What we have done is that we created a small tool that extracted all exchanges and queues names from RabbitMQ using HareDu. Then we compare the data with extract from "clean" env. and remove unused exchanges and queues (again using HareDu).

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Pavel Mihailov

unread,
Dec 22, 2018, 10:27:46 AM12/22/18
to masstransit-discuss
Hi Eric,
Yes, we deploy to a clean enviroment and let it run for a while. Also we then manually check whether all that we have to remove is really what we want to remove.
Additionally what you can do is to check whether class/inferface exists in your DLL. MT creates exchanges from from full class name. For comparison we reverse exchanges names back to C# names with namespaces and all generic stuff.

Eric Piraux

unread,
Dec 22, 2018, 10:47:19 AM12/22/18
to masstrans...@googlegroups.com

Nice, it'd be interesting to share your code on github !



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Pavel Mihailov

unread,
Dec 28, 2018, 2:00:32 AM12/28/18
to masstransit-discuss
Hi Eric,
I've extracted my code and pubkished it on github https://github.com/pmihailovs/rabbitmqcleaner

Eric Piraux

unread,
Dec 31, 2018, 10:52:11 AM12/31/18
to masstrans...@googlegroups.com
Cool, thank you, I'll try that asap.

Eric


Le ven. 28 déc. 2018 à 08:00, Pavel Mihailov <icera...@gmail.com> a écrit :
Hi Eric,
I've extracted my code and pubkished it on github https://github.com/pmihailovs/rabbitmqcleaner

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages