mardi 28 juillet 2020

How to build a java object from multiple data sources when data is not available in all sources during the creation time?

I've this design question that I'm trying to solve, and I hope to hear back from you, if you have any suggestions.

Let's say that we have a queue that you are listening to, the queue receives a message, the listener in your application grabs it, and builds an object, and pushes it to the cache, the object information at this moment has the data that it has received from the queue only, but it's still waiting on other data that's not available in other data sources (assume it's a DB) yet, what's the best approach to update the object when data becomes available in other data sources?

  • Should I've a thread running in the background to fetch data periodically?
  • I'm thinking of using decorator design pattern to build the object, Is that a good approach?
  • Any suggestions are welcome.

Aucun commentaire:

Enregistrer un commentaire