dimanche 5 juillet 2020

MongoDB - Design efficient way to calculate result

I am using Java, Spring-Boot and for db a mongodb. In mongo I have human collection structure like

{
  "_id": {
    "$oid": "5eaf79f4bce37709f84f6b03"
  },
  "claimNo": 123
  "xrays": [
    "xray1",
    "xray2",
    "xray3"
  ],
  "xray_details": {
    "xray1": {},
    "xray2": {},
    "xray3": {},
  },
  "claimResult": "A"
}

xrays object contains names of the xrays. xray_details contains detail information about each xray. So it is something like once we create this document initially; xray_details and claimResult doesn't contain any information. We get information as soon as it gets ready so e.g. for xray2 we may get some info but for xray3 and xray1 we may get info 15 mins later. What we need to do is that once we have some info then we need to calculate and update claimResult.

Detailed Explanation: In xray_details we get info for xray2 but xray1 and xray3 aren't available then we take into account only xray2 and update claimResult. As soon as we get some other xray information i.e. xray1 then we would use xray1, xray2 to calculate claimResult and once at later point we get xray3 then again we need to check/confirm whether do we already have info to use xray1, xray2,xray3 to calculate claimResult.

Problem: At this stage we are making a scheduler to calculate result but that isn't efficient and we need that, as soon as the information is available we take into account the previous completed ones and calculate the result again. Don't know whether solutions like kafka can work in this context or not but feel free to provide your valuable feedback/suggestions on this. Thanks!

Aucun commentaire:

Enregistrer un commentaire