Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support callbacks on connection or channel Shutdown and connection Blocking #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

michaelzg
Copy link

  • add functional test for handleShutdown using scalamock
  • add a note into the readme for handleShutdown and handleBlocking

Ref RabbitMQ Java Client 3.6.1:
ShutdownListener
BlockedListener

- add functional test for handleShutdown using scalamock

- add a note into the readme for handleShutdown and handleBlocking

- optimize imports
@mkiedys
Copy link
Contributor

mkiedys commented Nov 18, 2016

Can you explain why do you need this feature?

@mkiedys mkiedys force-pushed the master branch 3 times, most recently from 9d5fb44 to 531d688 Compare November 18, 2016 12:12
@michaelzg
Copy link
Author

@mkiedys Sure,

This is useful for monitoring and reacting when the connection to rabbit is down. (Logging, counting, prompt a reconnect). A workaround without this functionality, was to manually do a source.tick to generate a "heartbeat" of the RabbitConnection. That's inefficient and the detection is only as frequent as the tick interval.

Similar can be said for a blocked connection, it is very useful to me for monitoring.

@djamelz mentioned on Gitter advocating for this as well, maybe he can provide context for his motivation as well.

@djamelz
Copy link

djamelz commented Nov 21, 2016

Yes, i'm currently use it in production (via fork) to ensure the "based on callback" reconnection to rabbit. Combined with a retry mechanism it works very well !

@mkiedys
Copy link
Contributor

mkiedys commented Nov 22, 2016

Have you looked at supervision strategies?
http://doc.akka.io/docs/akka/2.4.12/scala/stream/stream-error.html

@michaelzg
Copy link
Author

michaelzg commented Nov 22, 2016

Yes, the supervision strategies were considered but found to be not optimal. Here are the two options I see in using supervision strategies and both do not come close to what the attached listeners can accomplish (but please let me know see something I don't).

Also worth mentioning a blocked connection (and its blocked listener) is useful to know and not something that stream supervision can portray explicitly.

  1. Separate Heartbeat stream for RabbitMQ connection. as mentioned previously via a source.tick, is inefficient and only as quick as the tick interval. Upon a down'ed RabbitMQ connection, this heartbeat tick stream will error out and the supervision restart logic will be in the handler--that same logic would easily slide right in the shutdown listener.

  2. Supervise the Publish/Subscribe stream and attempt to re-establish connection. The listeners will do a much better job than this option as well. I see two scenarios:

[A] when we have a fair number of pub/sub streams going into a rabbit connection (imagine having to restart thousands, multiple times until connection re-established so everyone is waiting and backing up). All those clients will have to raise a flag screaming at, say, an Actor to re-establish the connection. I'd rather see that Actor be able to monitor the RabbitMQ connection on it's own via the point above--but even better would be the listener.

[B] when the publish frequency is long (e.g. several minutes) and a down'd RabbitMQ connection will only be detected and acted upon when a publish fails. We can be more proactive with listeners to detect the trouble sooner and recover faster.

- Ensure open RabbitMQ channels are closed in the finalize method.
@arosien
Copy link

arosien commented Mar 20, 2017

I have a consulting client that uses this patch and having this merged into an official release would be fantastic! Anything I can do to help make that happen?

@michaelzg
Copy link
Author

I can help resolve the branch conflicts that arose over the months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants