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.