Menu

#49 Stateful Queue Binding maintenance

Sarra Beta
closed
nobody
None
7
2018-06-02
2016-08-26
psilva
No

currently, when one starts up sr_subscribe with

subtopic A

then stops the sr_subscribe, and edits the file to show

subtopic B

Then restart sr_subscribe, the result is that both bindings are set on the queue. The new binding is added, but the old binding is not, so the result is a subscription to A and B, rather than just B.

The reason for this is that the queue must be preserved one wishes to receive items which arrive during transient failures of the consumer. But the very permanence of the queue causes the bindings previously in place to be preserved across instances.

One can correct this unfortunate effect by invoking sr_subscribe with --reset option, to delete the queue and with it, the old binding. The queue will be re-created with only the new binding. Unfortunately that has the effect of discarding all items already queued.

AMQP does not provide any way to query what bindings are in effect, nor does it allow to delete bindings without specifying them exactly. In order to delete a binding one must know exactly what it is. When the configuration has changed, the program no longer has access to what the binding was before the change, and so it does not have the information required to delete the old bindings.

To correct the behaviour, one needs to treat bindings as statefully. Currently, sr_subscribe stores the name of the queue in the user_cache_dir. One would need to add more content to the state directory to document the bindings in place when the subscribe was initiated.

When sr_subscribe starts up, need to compare the stored bindings with the bindings set by the current configuration, removing obsolete ones and adding the new ones. Then save the bindings to the binding state file.

This was all discussed with sr_subscribe as an example, but it applies equally to all consumers.

Discussion

  • psilva

    psilva - 2016-11-12

    thinking about --reset stop

    sr_whatever --reset stop.

    would mean to connect to the configured broker, and delete the queue.

     
  • psilva

    psilva - 2016-12-10
    • Priority: 5 --> 7
     
  • psilva

    psilva - 2018-06-02
     
  • psilva

    psilva - 2018-06-02
    • status: open --> closed
     
MongoDB Logo MongoDB