Skip to content

add: send mysql_to_rabbitmq.py #547

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
Oct 19, 2023

Conversation

myminju
Copy link

@myminju myminju commented Oct 15, 2023

closes #545

@myminju myminju changed the title Add: send mysql_to_rabbitmq.py add: send mysql_to_rabbitmq.py Oct 15, 2023
Comment on lines +42 to +54
for binlogevent in stream:
for row in binlogevent.rows:
if isinstance(binlogevent, DeleteRowsEvent):
routing_key = "order"
message_body = row["values"].items()

elif isinstance(binlogevent, UpdateRowsEvent):
routing_key = "order"
message_body = row["after_values"].items()

elif isinstance(binlogevent, WriteRowsEvent):
routing_key = "order"
message_body = row["values"].items()
Copy link
Collaborator

Choose a reason for hiding this comment

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

better use routing_key just once.
and I think routing_key == order is little bit Doesn't fit.

@dongwook-chan
Copy link
Collaborator

I'm gonna test this on local RabbitMQ

@dongwook-chan
Copy link
Collaborator

I have tested your code thoroughly.
It works fine in general.
However in cases where the column types are temporal (i.e. timestamp or datetime) or JSON,
I got serialization issues.
So I updated to code so that the incompatible column values can be cast to str before being serialized to JSON.

@dongwook-chan dongwook-chan merged commit b72d476 into julien-duponchelle:main Oct 19, 2023
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.

Add Send an Event MySQL to RabbitMQ
3 participants