diff --git a/solarnet/datum/src/main/java/net/solarnetwork/central/datum/flux/SolarFluxDatumPublisher.java b/solarnet/datum/src/main/java/net/solarnetwork/central/datum/flux/SolarFluxDatumPublisher.java index f107b08aa..9ebc083b8 100644 --- a/solarnet/datum/src/main/java/net/solarnetwork/central/datum/flux/SolarFluxDatumPublisher.java +++ b/solarnet/datum/src/main/java/net/solarnetwork/central/datum/flux/SolarFluxDatumPublisher.java @@ -44,7 +44,7 @@ * Publish datum to SolarFlux. * * @author matt - * @version 2.1 + * @version 2.2 */ public class SolarFluxDatumPublisher extends MqttJsonPublisher> implements DatumProcessor { @@ -65,7 +65,13 @@ public class SolarFluxDatumPublisher extends MqttJsonPublisher 0 ) { + final long now = System.currentTimeMillis(); + final long tdiff = errorLogLimitMs > 0 ? now - lastErrorTime : lastErrorTime; + if ( tdiff >= lastErrorTime ) { + logPublishError(e, root, aggregation); + lastErrorTime = now; + } else { + log.debug("Problem publishing {} datum to SolarFlux: {}", + aggDisplayName(aggregation), root.getMessage()); + } } else { - log.error("Error publishing {} datum to SolarFlux: {}", aggDisplayName(aggregation), - root.toString(), e); + logPublishError(e, root, aggregation); } } return false; } + private void logPublishError(Throwable e, Throwable root, Aggregation aggregation) { + if ( (root instanceof RemoteServiceException) + || (root instanceof net.solarnetwork.service.RemoteServiceException) ) { + log.warn("Problem publishing {} datum to SolarFlux: {}", aggDisplayName(aggregation), + root.getMessage()); + } else { + log.error("Problem publishing {} datum to SolarFlux: {}", aggDisplayName(aggregation), + root.toString(), e); + } + } + private static String aggDisplayName(Aggregation aggregation) { return aggregation == Aggregation.None ? "Raw" : aggregation.toString(); } @@ -194,4 +216,25 @@ private String topicForDatum(Aggregation aggregation, Identity