service - How to publish data changes between databases within RabbitMQ? -
suppose have 2 applications a , b own different databases a1 (mysql) , b1 (postgres) correspondingly. create entities x , y associated each other in application a. y belongs x. on every insert database a1 (after commit) publish message rabbitmq make application b aware of brand new entities. 1 event per entity – x1 , y1. good, if rabbitmq keeps order of messages, workers in application b may process x1 first , y1 second establish right association between new a , b records in database b1. far understand rabbitmq not intended keep messages order , in specific circumstances, publish within 1 channel, send 1 exchange, push 1 queue, consume within 1 channel.
so question correct direction , general approach:
- should choose message queue, guarantees messages order?
- have missed specific in rabbitmq messages order specifics?
- should implement kind of retry mechanism in application
bside, re-enqueue messages rabbitmq in case if message order not expected?
maybe give more sensible context – b1 data warehouse, aggregates data not a1, other databases.
everything good, if rabbitmq keeps order of messages
is solution? can't x , y instances sequence number assigned, used rebuild right sequence within b?
to establish right association between new , b records
can't x1, y1 express explicit relation allowing creation of a, b without relying on sequence?
the point is: message ordering expensive. either have hard constraints (e.g. 1 consumer) or have less availability , speed. best bet finding way not rely on order.
Comments
Post a Comment