Use a callback to log errors on failure for improved error reporting
This commit is contained in:
parent
8dc9a68c62
commit
d917c72d51
@ -604,7 +604,9 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
|
||||
var tenantId = stateData.getTenantId();
|
||||
var deviceId = stateData.getDeviceId();
|
||||
|
||||
Futures.whenAllSucceed(save(tenantId, deviceId, ACTIVITY_STATE, active)).run(() -> {
|
||||
Futures.addCallback(save(tenantId, deviceId, ACTIVITY_STATE, active), new FutureCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(Void success) {
|
||||
stateData.getState().setActive(active);
|
||||
pushRuleEngineMessage(stateData, active ? TbMsgType.ACTIVITY_EVENT : TbMsgType.INACTIVITY_EVENT);
|
||||
TbMsgMetaData metaData = stateData.getMetaData();
|
||||
@ -617,6 +619,12 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
|
||||
.deviceType(metaData.getValue("deviceType"))
|
||||
.deviceLabel(metaData.getValue("deviceLabel"))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Throwable t) {
|
||||
log.error("[{}][{}] Failed to change device activity status to '{}'. Device state data: {}", tenantId, deviceId, active, stateData, t);
|
||||
}
|
||||
}, deviceStateCallbackExecutor);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user