bunny icon indicating copy to clipboard operation
bunny copied to clipboard

Automatic reconnect

Open jakubkulhan opened this issue 8 years ago • 5 comments

  • [ ] Client option to allow reconnect (+ reconnect timeout)
  • [ ] open all previously opened channels
  • [ ] start all previously started consumers
    • what about anonymous queues?
  • [ ] return callbacks
  • [ ] confirm callbacks
  • [ ] MAYBE: declare all previously declared queues
    • only anonymous queues?
  • [ ] MAYBE: declare all previously declared exchanges

jakubkulhan avatar Jun 18 '16 21:06 jakubkulhan

The main problem with automatic reconnect is that exceptions are thrown directly (no link with the promise). The usual errors (during inactivity or network latencies) are then thrown by the event loop [https://github.com/jakubkulhan/bunny/blob/master/src/Bunny/AbstractClient.php#L282]. The only way to catch error is to try catch the eventloop (not optimal)

How can I help to extract the broken pipe and link it with the produce or consume promise ?

Vinceveve avatar Nov 07 '16 17:11 Vinceveve

Yes, rejecting pending promises should also be performed, however, it won't suffice alone.

jakubkulhan avatar Nov 09 '16 08:11 jakubkulhan

Here is a POC (with some reactiveX flavour) https://github.com/Domraider/bunny/blob/master/README.md

Updated to handle channel re-opening.

Solution was to wait for client to be connected : https://github.com/Domraider/bunny/blob/master/src/Bunny/Channel.php#L123

and reopen channel when connect is done : https://github.com/Domraider/bunny/blob/master/src/Bunny/Async/Client.php#L288

Vinceveve avatar Nov 16 '16 16:11 Vinceveve

+1 on using Rx to solve this problem

cboden avatar Nov 16 '16 18:11 cboden