0

My application interacts with an external system. There are multiple request-response interactions for a single business case. This information (request and response messages) is also logged in MongoDB. The structure is similar to:

{
 _id: ObjectId("..."),
 caseId: "PRC-122",
 msg_date: ISODate("2017-06-10T11:21:41.112Z"),
 type: "REQUEST",
     systemId: "ASR",
 message: ""
}

For now, MongoDB information is used mostly for post-action troubleshooting. Assume that some business case ends with a failure. So we could get all the messages in the scope of this case (caseId) and see the reason of failure (SOAPFault, for example). Now I need to prepare some quality of service report. Assume that there is a chain of messages in the scope of the single business case. I need to calculate the time interval (in hours) between the first request to an external system and the last response of it. I don't understand how to create this kind of query. I know that MongoDB has an aggregation feature but it doesn't help me all.

-2

Aggregation feature is the wrong way here. MongoDb provides Map-reduce functions https://docs.mongodb.com/manual/tutorial/map-reduce-examples/ Basically, in your "map" function you need to get the date values grouped by caseId. And the calculation of time interval should be put in the "reduce" function. If you have difficulties with this you can ask these guys www.issart.com . I sometimes use the help of these guys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.