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

Try to reconnect if connection is lost (replace pika with kombu) #55

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

Conversation

matt-snider
Copy link
Contributor

I need the AMQPLogstashHandler to gracefully handle connection failure. Rather than implement this logic in the library as in #34, I recommend switching from pika to kombu.

In this PR I essentially just swapped the two libraries and made updates necessary to accommodate that change. This implementation uses kombu's producers pool for publishing, which handles connection failure gracefully. It might also be a good idea to add a max pool size option to the AMQPLogstashHandler (see setting pool limits).

I also updated the socket logic to be more compatible with the SocketHandler class. With the current implementation, we are made aware of connection problems because pika raises pika.exceptions.ConnectionClosed, which escapes the except-block in SocketHandler.createSocket(). With kombu, OSErrors are raised, which get silently swallowed, so I had to add a modified send().

Using kombu avoids having to implement redirect logic.
Allowing connection errors to occur makeSocket() causes the
failure logic (e.g. exponential backoff, reconnect, etc) from
SocketHandler to be triggered.

Reraising exceptions in send() allows them to bubble up to emit() and
be reported so that they don't just get silently swallowed.
@matt-snider
Copy link
Contributor Author

@vklochan Hey! I saw you commented on the other PR and thought perhaps you had overlooked this one. Let me know if it addresses some of the issues with the previous PRs appropriately

@cp2587
Copy link

cp2587 commented Oct 24, 2016

I think this is a great addition to the library. Right now, messages a silently dropped after a connection failure

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.

2 participants