dart_amqp icon indicating copy to clipboard operation
dart_amqp copied to clipboard

auto-delete for exchanges

Open jodinathan opened this issue 5 years ago • 2 comments

there isn't an option to set the auto-delete flags for exchange. I was digging the source and you kinda use some source generator, right? Can you explain a little bit about it? So then I can add the flag :)

jodinathan avatar Jun 03 '19 23:06 jodinathan

Hi there.

You are correct. The generate_bindings tool basically reads the amqp specification from an XML document (available here) and creates the bindings which are stored in the bindings folder.

The XML document defines <class> elements which specify high-level groups such as channels, queues, exchanges e.t.c. Within each <class> you will see a number of <method> blocks which essentially correspond to the messages send between the client and the amqp server. The bindings-generator creates an object for each method definition. To avoid name clashes, the name of each object includes its parent class name as a prefix (e.g ChannelOpen, ChannelOpenOk e.t.c). Finally, each <method> block defines zero or more fields which get mapped as attributes within each defined object. Based on the types of each field, the generator also emits the appropriate constructor and serialization methods which handle the low-level conversions from/to the wire protocol.

Regarding your initial question, it seems like auto-delete for exchanges is deprecated. This is the relevant line from the XML doc:

<!--  Deprecated: "auto-delete", must be zero  -->
<field name="reserved-2" type="bit" reserved="1"/>

However, auto-delete seems to be supported for queues though (see here). Would that work for your particular use-case?

achilleasa avatar Jun 05 '19 17:06 achilleasa

thanks for your response. My case is that I have groups of users that receive messages. The messages can only be seen within the group and they can be read by many consumers per user. I am ending up having to create several exchanges of type fanout and I have the feeling that this is not correct. I tried with topic type of exchange but from my tests, it does not work as a broadcaster. Once the first consumer reads the message, it stops there and the others consumers do not receive it. So I was thinking that if the fanout exchange was auto-deleted after the group was closed (all queues deleted), then it would be ok. Am I missing something about the topic type? Or any other amqp stuff that can work here?

jodinathan avatar Jun 05 '19 17:06 jodinathan