Search code examples
javadesign-patternsdatabase-designanti-patterns

Is this considered as a "Database as an IPC" antipattern?


I started to develop an application which consists of two parts. The whole system acts as a digital signage application. Everything is located at one physical machine.

First component is an administration backend for the content management. Users can schedule and upload multimedia files. This is web based thing available via browser.

The second part is a media player. Its task is basically to load data which people uploaded and display them. Metadata for those are saved in a database (e.g. how long should it display this picture, what goes next ...) and physical data in the filesystem since it is all on the same machine.

All related data are stored in PostgreSQL database. There are basicaly schedule information + filesystem paths of content - not their binary form.

There is a socket connection through local loop between those two. There is some really simple communication and command parsing (status check, exit, refresh content). If user uploads and schedules new content or changes current one via webbased backend - a message via socket is sent to media player which tells him to build a new schedule.

However as soon as player recieves a message to check for new content, it loads scheduling data from database.

I would like to know if this is considered as a Database as an IPC antipattern? If yes what would be better ways of solving it?


Solution

  • Does not sound like it at all to me. The scheduling data is something persistent, no? Schedules can be recurring, last for a long time? Getting them from the database is fine.

    "Database as IPC" would be if you sent "messages" by inserting say, an "exit"-row in the database and the media player decided when to exit by querying that table and checking for an "exit message" in it every 15 seconds or something.

    There's nothing wrong with Process A inserting data, then sending a message to Process B that says "I have created new data you may be interested in" as long as the data you created is actually persistent data that belongs in a database. It's only a problem if what you're putting in the database isn't actually persistent data and you're just using is as a transient intermediate step.