Skip to content

Reconnect the connection thread if broker shuts down #18

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

Merged
merged 2 commits into from
Jan 29, 2020

Conversation

t-persson
Copy link
Collaborator

Make the subscriber and publisher interfaces more clear and stable.
Reconnect if the rabbitmq broker shuts down.
Configurable parameters for how many threads the subscriber is
allowed to create.
Keep track of published messages in order to requeue them if broker
goes down.
Create a base RabbitMQ class for shared methods.

Applicable Issues

fixes: #15
fixes: #16

Description of the Change

Reconnect the subscribers and publishers if RabbitMQ should go down for some reason.

Alternate Designs

Redesigned the code to utilize the SelectConnection instead of BlockingConnection of pika.
SelectConnection means async calls instead of sync calls of the BlockingConnection.
The BlockingConnection makes more understandable code whereas the SelectConnection is more reliable (We don't have to force thread-safety into a non-thread-safe tool).

Benefits

Reconnection is always good. More reliable code.

Possible Drawbacks

Could make it harder to maintain if one has problems with the SelectConnection.

Sign-off

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

Signed-off-by: Tobias Persson [email protected]

Make the subscriber and publisher interfaces more clear and stable.
Reconnect if the rabbitmq broker shuts down.
Configurable parameters for how many threads the subscriber is
allowed to create.
Keep track of published messages in order to requeue them if broker
goes down.
Create a base RabbitMQ class for shared methods.
Copy link
Member

@magnusbaeck magnusbaeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fix the default routing key as noted in my comment but that can be done in a follow-up PR if you like.

Added default value of '#' to routing key.
Changed '%s' to %r
@t-persson t-persson requested a review from magnusbaeck January 29, 2020 07:36
@t-persson t-persson merged commit ff11b12 into master Jan 29, 2020
@t-persson t-persson deleted the issue_16_test_branch branch January 29, 2020 08:19
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.

Connection thread dies when broker shuts down No retries take place if initial RabbitMQ connection can't be made
2 participants