class NotificationManager {

    @Transactional(propagation = Propagation.REQUIRED)
    public void notifyLongRunningTask(PipelineRun run, Long duration, NotificationSettings settings) {
        LOGGER.debug(messageHelper.getMessage(MessageConstants.INFO_NOTIFICATION_SUBMITTED, run.getPodId()));

        final String instanceTypesToExclude = preferenceManager.getPreference(SystemPreferences
                .SYSTEM_NOTIFICATIONS_EXCLUDE_INSTANCE_TYPES);

        if (!noneMatchExcludedInstanceType(run, instanceTypesToExclude)) {
            return;
        }

        NotificationMessage notificationMessage = new NotificationMessage();

        if (settings.isKeepInformedOwner()) {
            PipelineUser pipelineOwner = userManager.loadUserByName(run.getOwner());
            notificationMessage.setToUserId(pipelineOwner.getId());
        }

        notificationMessage.setCopyUserIds(getCCUsers(settings));

        notificationMessage.setTemplate(new NotificationTemplate(settings.getTemplateId()));
        if (notificationMessage.getTemplate() == null) {
            LOGGER.error(messageHelper.getMessage(MessageConstants.ERROR_NOTIFICATION_NOT_FOUND,
                    settings.getTemplateId()));
        }

        notificationMessage.setTemplateParameters(PipelineRunMapper.map(run, settings.getThreshold(), duration));
        monitoringNotificationDao.createMonitoringNotification(notificationMessage);
    }

}