Email Notification on Error
NOTE: Starting with SymmetricDS 3.8, it includes monitors with notifications over email.
A load filter can be used to send an email when a batch has an error. Starting with SymmetricDS 3.3.2, a single load filter can be applied to all tables to handle errors.
Configure Load Filter
1 - Create a new load filter. Go to Configure->Load Filters and click the "New" button. Enter the following information:
Filter Id: EMAIL_ERROR Group Link: server waits for pull from client Type: BSH Target Catalog: (left blank) Target Schema: (left blank) Target Table: (left blank) Filter on Update: (selected) Filter on Insert: (selected) Filter on Delete: (selected) Filter Order: 0 Fail on Error: (selected)
2 - Save the filter. It will show up on the list of filters.
3 - Highlight the row with the filter by clicking it, then click the "Edit Scripts" button.
4 - Change the drop down to "Handle Error Script".
5 - Enter the following BeanShell script:
authListener = new javax.mail.Authenticator() { protected javax.mail.PasswordAuthentication getPasswordAuthentication() { return new javax.mail.PasswordAuthentication(engine.getParameterService().getString("mail.smtp.username"), engine.getParameterService().getString("mail.smtp.password")); } }; if (bsh.shared.mailMap == void) { bsh.shared.mailMap = new HashMap(); } String batchId = context.getBatch().getSourceNodeBatchId(); String targetNodeId = context.getBatch().getTargetNodeId(); if (!bsh.shared.mailMap.containsKey(batchId)) { bsh.shared.mailMap.put(batchId, Boolean.TRUE); javax.mail.Session session = javax.mail.Session.getInstance (engine.getParameterService().getAllParameters(), authListener); javax.mail.internet.MimeMessage msg = new javax.mail.internet.MimeMessage(session); msg.setFrom(new javax.mail.internet.InternetAddress (engine.getParameterService().getString("mail.smtp.from"))); msg.setRecipients(javax.mail.Message.RecipientType.TO, engine.getParameterService().getString("mail.smtp.to")); msg.setSubject("SymmetricDS - batch " + batchId + " is in error at node " + targetNodeId); msg.setSentDate(new java.util.Date()); msg.setText(org.apache.commons.lang.exception.ExceptionUtils. getFullStackTrace(error)); javax.mail.Transport.send(msg); }
6 - Set the following properties in your properties files:
mail.smtp.auth=true mail.smtp.starttls.enable=true mail.smtp.host= mail.smtp.port= mail.smtp.username= mail.smtp.password= mail.smtp.from= mail.smtp.to=