Loading src/main/java/es/redmic/brokerlib/alert/AlertService.java +29 −2 Original line number Diff line number Diff line package es.redmic.brokerlib.alert; import javax.annotation.PostConstruct; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; Loading @@ -22,13 +24,38 @@ public class AlertService { @Value("${spring.profiles.active}") private String PROFILE_ACTIVE; @Value("${info.vessels-commands.name}") private String MICROSERVICE_NAME; private String subjectDefault; @PostConstruct private void AlertServicePostConstruct() { subjectDefault = "[" + MICROSERVICE_NAME + "][" + PROFILE_ACTIVE + "]"; } @Autowired private KafkaTemplate<String, Message> kafkaTemplate; public void infoAlert(String subject, String message) { alert(subject, message, AlertType.INFO.name()); } public void warnAlert(String subject, String message) { alert(subject, message, AlertType.WARN.name()); } public void errorAlert(String subject, String message) { String subjectDefault = "[ERROR][" + PROFILE_ACTIVE + "] "; send(new Message(ALERT_EMAIL, subjectDefault + subject, message, AlertType.ERROR.name())); alert(subject, message, AlertType.ERROR.name()); } public void alert(String subject, String message, String type) { send(new Message(ALERT_EMAIL, subjectDefault + "[" + type + "] " + subject, message, type)); } private void send(Message message) { Loading Loading
src/main/java/es/redmic/brokerlib/alert/AlertService.java +29 −2 Original line number Diff line number Diff line package es.redmic.brokerlib.alert; import javax.annotation.PostConstruct; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; Loading @@ -22,13 +24,38 @@ public class AlertService { @Value("${spring.profiles.active}") private String PROFILE_ACTIVE; @Value("${info.vessels-commands.name}") private String MICROSERVICE_NAME; private String subjectDefault; @PostConstruct private void AlertServicePostConstruct() { subjectDefault = "[" + MICROSERVICE_NAME + "][" + PROFILE_ACTIVE + "]"; } @Autowired private KafkaTemplate<String, Message> kafkaTemplate; public void infoAlert(String subject, String message) { alert(subject, message, AlertType.INFO.name()); } public void warnAlert(String subject, String message) { alert(subject, message, AlertType.WARN.name()); } public void errorAlert(String subject, String message) { String subjectDefault = "[ERROR][" + PROFILE_ACTIVE + "] "; send(new Message(ALERT_EMAIL, subjectDefault + subject, message, AlertType.ERROR.name())); alert(subject, message, AlertType.ERROR.name()); } public void alert(String subject, String message, String type) { send(new Message(ALERT_EMAIL, subjectDefault + "[" + type + "] " + subject, message, type)); } private void send(Message message) { Loading