Commit 9c52ffc3 authored by 赵啸非's avatar 赵啸非

修改redis 过期事件通知

parent a94e573c
......@@ -51,8 +51,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
return data.getDeviceCode();
}
@Autowired
private MessageService messageService;
@Autowired
......@@ -222,27 +220,32 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
protected void removeBefore(Long[] ids, Context context) throws AppException {
Arrays.asList(ids).stream().forEach(id -> {
DeviceEntity deviceEntity = this.get(id, context);
TbQueueCallback callback = new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
log.info("队列删除成功");
}
if (!ObjectUtils.isEmpty(deviceEntity)) {
@Override
public void onFailure(Throwable t) {
log.error("队列删除失败", t);
}
};
messageService.delQueue(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode(), callback);
messageService.delQueue(Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(), callback);
TbQueueCallback callback = new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
log.info("队列删除成功");
}
@Override
public void onFailure(Throwable t) {
log.error("队列删除失败", t);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceStatusEnum.DEL);
}
};
messageService.delQueue(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode(), callback);
messageService.delQueue(Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(), callback);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceStatusEnum.DEL);
}
//删除扩展extKey
this.removeCache(deviceEntity.getDeviceCode());
}
});
super.removeBefore(ids, context);
......
......@@ -71,7 +71,7 @@ POST {{baseUrl}}/api/register
Content-Type: application/json
{
"deviceCode": "b12345678"
"deviceCode": "c12345678"
}
> {%
......@@ -108,7 +108,7 @@ Content-Type: application/json
Authorization: {{authToken}}
{
"deviceCode": "b12345678",
"deviceCode": "c12345678",
"action": "upload"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment