22 |
|
|
23 |
Properties props; |
Properties props; |
24 |
|
|
25 |
public MailNotifier(CircuitBreaker cb, String from, String recipient, String mailhost) { |
public MailNotifier(String from, String recipient, String mailhost) { |
|
super(cb); |
|
26 |
|
|
27 |
this.from = from; |
this.from = from; |
28 |
this.recipient = recipient; |
this.recipient = recipient; |
33 |
|
|
34 |
|
|
35 |
@Override |
@Override |
36 |
public void sendAsync(String breakerName, Event evnt) { |
public void sendAsync(CircuitBreaker breaker, Event evnt) { |
37 |
try { |
try { |
38 |
if (evnt == Event.BreakerTripped || evnt == Event.BreakerReset) { |
if (evnt == Event.BreakerTripped || evnt == Event.BreakerReset) { |
39 |
// create some properties and get the default Session |
// create some properties and get the default Session |
47 |
msg.setFrom( new InternetAddress(from) ); |
msg.setFrom( new InternetAddress(from) ); |
48 |
|
|
49 |
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient) ); |
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient) ); |
50 |
msg.setSubject("Circuitbreaker " + breakerName + " : " + evnt.toString()); |
msg.setSubject("Circuitbreaker " + breaker.getName() + " : " + evnt.toString()); |
51 |
msg.setText("--"); |
msg.setText("--"); |
52 |
|
|
53 |
Transport.send(msg); |
Transport.send(msg); |
55 |
} catch (Exception e) { |
} catch (Exception e) { |
56 |
logger.warning("Unable to send CircuitBreaker notification mail " + e ); |
logger.warning("Unable to send CircuitBreaker notification mail " + e ); |
57 |
} |
} |
|
|
|
|
|
|
58 |
} |
} |
59 |
|
|
60 |
} |
} |