Imagine that we are building a job application system using a set of microservices. This system needs to process job applications based on a defined workflow (i.e. a sequence/set of tasks) to completion.
For example, the set of tasks for a job application workflow may look like this:
In addition: #4 and #5 can be done in parallel.
Given the set of tasks, we may then have a set of microservices like this:
Perhaps a simple solution is to maintain a STATUS
column in the APPLICATION_DETAIL
table itself. This column would show the status such as ‘Submission’, ‘Phone Screen’, ‘On-site Interview’, etc…
CREATE TABLE APPLICATION_DETAIL (
ID INT PRIMARY KEY NOT NULL,
FIRST_NAME CHAR(100),
LAST_NAME CHAR(100),
POSITION CHAR(100),
STATUS CHAR(50)
);
ID | FIRST_NAME | LAST_NAME | POSITION | STATUS |
---|---|---|---|---|
1 | PETER | PARKER | SOFTWARE ENGINEER | SUBMISSION |
2 | MARY | JANE | RECRUITER | PHONE_SCREEN |
3 | HARRY | OSBORN | SITE RELIABILITY ENGINEER | ON_SITE_INTERVIEW |
4 | GWEN | STACY | ENGINERING MANAGER | OFFER |
This solution may work alright if:
We quickly observe that this would not work well for our job application system given that:
Use a STATUS
table to maintain the statuses of all your microservices:
CREATE TABLE APPLICATION_STATUS (
ID INT FOREIGN KEY NOT NULL,
PHONE_SCREEN_STATUS CHAR(50),
ON_SITE_INTERVIEW_STATUS CHAR(50),
BACKGROUND_CHECK_STATUS CHAR(50),
HEALTH_SCREENING_STATUS CHAR(50),
OFFER_STATUS CHAR(50)
);
ID | APPLICATION_SERVICE | PHONE_SCREEN_STATUS | ON_SITE_INTERVIEW_STATUS | BACKGROUND_CHECK_STATUS | HEALTH_SCREENING_STATUS | OFFER_STATUS |
---|---|---|---|---|---|---|
1 | DRAFT | |||||
2 | SUBMITTED | PENDING | ||||
3 | SUBMITTED | PASSED | PASSED | PENDING | PENDING | |
4 | SUBMITTED | PASSED | PASSED | PENDING | PENDING | |
5 | SUBMITTED | PASSED | PASSED | FAILED | CANCELLED | NO_OFFER |
6 | SUBMITTED | PASSED | PASSED | PASSED | PASSED | ACCEPTED |
Pros:
Cons: