class StackStatusHandler {

    @Async
    public void updateStackStatus(Stack stack) {
        try {
            String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
            String stackStatus = mapper.writeValueAsString(stack);
            RequestProcessingData requestProcessingData =
                    requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId,
                            stack.getStackName(), stack.getId());
            if (requestProcessingData == null) {
                requestProcessingData = new RequestProcessingData();
                requestProcessingData.setGroupingId(stack.getId());
                requestProcessingData.setName(stack.getStackName());
                requestProcessingData.setTag("StackInformation");
                requestProcessingData.setSoRequestId(requestId);
                requestProcessingData.setValue(stackStatus);
                requestDBClient.saveRequestProcessingData(requestProcessingData);
            } else {
                requestProcessingData.setValue(stackStatus);
                requestDBClient.updateRequestProcessingData(requestProcessingData);
            }
        } catch (Exception e) {
            logger.warn("Error adding stack status to request database", e);
        }
    }

}