Fix for Bug #5931
This commit is contained in:
parent
ced4f23908
commit
519e05bd11
@ -19,6 +19,7 @@ import com.google.common.util.concurrent.FutureCallback;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.asset.Asset;
|
||||
import org.thingsboard.server.common.data.id.AssetId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -95,7 +96,8 @@ public class DefaultRuleEngineStatisticsService implements RuleEngineStatisticsS
|
||||
}
|
||||
});
|
||||
ruleEngineStats.getTenantExceptions().forEach((tenantId, e) -> {
|
||||
TsKvEntry tsKv = new BasicTsKvEntry(ts, new JsonDataEntry("ruleEngineException", e.toJsonString()));
|
||||
TsKvEntry tsKv = new BasicTsKvEntry(e.getTs(), new JsonDataEntry("ruleEngineException",
|
||||
JacksonUtil.toString(JacksonUtil.newObjectNode().put("message", e.getMessage()))));
|
||||
try {
|
||||
tsService.saveAndNotifyInternal(tenantId, getServiceAssetId(tenantId, queueName), Collections.singletonList(tsKv), CALLBACK);
|
||||
} catch (DataValidationException e2) {
|
||||
|
||||
@ -17,22 +17,19 @@ package org.thingsboard.server.common.msg.queue;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class RuleEngineException extends Exception {
|
||||
protected static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Getter
|
||||
private final long ts;
|
||||
|
||||
public RuleEngineException(String message) {
|
||||
super(message != null ? message : "Unknown");
|
||||
this.ts = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String toJsonString() {
|
||||
try {
|
||||
return mapper.writeValueAsString(mapper.createObjectNode().put("message", getMessage()));
|
||||
} catch (JsonProcessingException e) {
|
||||
log.warn("Failed to serialize exception ", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user