2

Suppose there is a microservice that has an restful HTTP API for CRUD operations on a database - nothing fancy, but there is a journal table of all changes recorded for audit purposes. Suppose also there is an event bus (in my case Kafka, but could be anything) to which data change events must be published.

The journal table has sufficient information to create all events.

The options on the table are:

  1. Microservice publishes its own events
  2. Another application publishes events based on polling the journal table

Both options guarantee that all events will (eventually) be published, and have similar performance and similar, simple design complexity both approaches will be 100% robust.

Things to consider, which may or may not affect the answer:

  • performance is similar, and largely irrelevant anyway
  • while the journal table is not expected to change, option 2 means having a foreign application depending on it thus creating an API/SLA that is tightly coupled to an implementation choice (using a table for the journal) and its schema.
  • option 2 requires DB connection credentials, network routing, security signoff, certificates, etc
  • option 1 means the microservice has the increased responsibility of publishing events
  • option 2 means there is another application to build, deploy, operate and maintain
  • both options will work

Which is (closer to) best practice?

asked Jan 21, 2020 at 6:40

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.