Commit 1ba0b6aa by 111-PC\111

[+]kafka消费数据修改

1 parent 3945d97e
...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver; ...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver;
import cn.com.glsx.smart.service.SmartDeviceStatusService; import cn.com.glsx.smart.service.SmartDeviceStatusService;
import cn.com.glsx.smart.utils.ProtobufConvert; import cn.com.glsx.smart.utils.ProtobufConvert;
import cn.com.glsx.smart.vo.Event; import cn.com.glsx.smart.vo.Event;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author zhouhaibao * @author zhouhaibao
* @date 2021/4/10 18:12 * @date 2021/4/10 18:12
*/ */
@Slf4j
public class EdrFlameOutConsumer extends MessageReceiver { public class EdrFlameOutConsumer extends MessageReceiver {
...@@ -20,10 +22,15 @@ public class EdrFlameOutConsumer extends MessageReceiver { ...@@ -20,10 +22,15 @@ public class EdrFlameOutConsumer extends MessageReceiver {
@Override @Override
public void processMessage(String topic, byte[] message) { public void processMessage(String topic, byte[] message) {
Event event =ProtobufConvert.convertFlameOut(message); try {
Event event = ProtobufConvert.convertFlameOut(message);
if (event == null) { if (event == null) {
return; return;
} }
smartDeviceStatusService.saveEvent(event); smartDeviceStatusService.saveEvent(event);
} catch (Exception e) {
e.printStackTrace();
log.info("topic{}消费异常", topic);
}
} }
} }
...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver; ...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver;
import cn.com.glsx.smart.service.SmartDeviceStatusService; import cn.com.glsx.smart.service.SmartDeviceStatusService;
import cn.com.glsx.smart.utils.ProtobufConvert; import cn.com.glsx.smart.utils.ProtobufConvert;
import cn.com.glsx.smart.vo.Event; import cn.com.glsx.smart.vo.Event;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author zhouhaibao * @author zhouhaibao
* @date 2021/4/10 16:51 * @date 2021/4/10 16:51
*/ */
@Slf4j
public class EdrIgnitionConsumer extends MessageReceiver { public class EdrIgnitionConsumer extends MessageReceiver {
@Autowired @Autowired
...@@ -19,11 +21,17 @@ public class EdrIgnitionConsumer extends MessageReceiver { ...@@ -19,11 +21,17 @@ public class EdrIgnitionConsumer extends MessageReceiver {
@Override @Override
public void processMessage(String topic, byte[] message) { public void processMessage(String topic, byte[] message) {
try {
Event event = ProtobufConvert.convertIgnition(message); Event event = ProtobufConvert.convertIgnition(message);
if (event == null) { if (event == null) {
return; return;
} }
smartDeviceStatusService.saveEvent(event); smartDeviceStatusService.saveEvent(event);
} catch (Exception e) {
e.printStackTrace();
log.info("topic{}消费异常", topic);
}
} }
} }
...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver; ...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver;
import cn.com.glsx.smart.service.SmartDeviceStatusService; import cn.com.glsx.smart.service.SmartDeviceStatusService;
import cn.com.glsx.smart.utils.ProtobufConvert; import cn.com.glsx.smart.utils.ProtobufConvert;
import cn.com.glsx.smart.vo.Event; import cn.com.glsx.smart.vo.Event;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -12,18 +13,23 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,18 +13,23 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author zhouhaibao * @author zhouhaibao
* @date 2021/4/10 18:12 * @date 2021/4/10 18:12
*/ */
@Slf4j
public class GPSFlameOutConsumer extends MessageReceiver { public class GPSFlameOutConsumer extends MessageReceiver {
@Autowired @Autowired
private SmartDeviceStatusService smartDeviceStatusService; private SmartDeviceStatusService smartDeviceStatusService;
@Override @Override
public void processMessage(String topic, byte[] message) { public void processMessage(String topic, byte[] message) {
Event event =ProtobufConvert.convertFlameOut(message); try {
Event event = ProtobufConvert.convertFlameOut(message);
if (event == null) { if (event == null) {
return; return;
} }
smartDeviceStatusService.saveEvent(event); smartDeviceStatusService.saveEvent(event);
} catch (Exception e) {
e.printStackTrace();
log.info("topic{}消费异常", topic);
}
} }
} }
...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver; ...@@ -4,6 +4,7 @@ import cn.com.glsx.smart.queue.base.MessageReceiver;
import cn.com.glsx.smart.service.SmartDeviceStatusService; import cn.com.glsx.smart.service.SmartDeviceStatusService;
import cn.com.glsx.smart.utils.ProtobufConvert; import cn.com.glsx.smart.utils.ProtobufConvert;
import cn.com.glsx.smart.vo.Event; import cn.com.glsx.smart.vo.Event;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author zhouhaibao * @author zhouhaibao
* @date 2021/4/10 16:51 * @date 2021/4/10 16:51
*/ */
@Slf4j
public class GpsIgnitionConsumer extends MessageReceiver { public class GpsIgnitionConsumer extends MessageReceiver {
@Autowired @Autowired
...@@ -19,11 +21,16 @@ public class GpsIgnitionConsumer extends MessageReceiver { ...@@ -19,11 +21,16 @@ public class GpsIgnitionConsumer extends MessageReceiver {
@Override @Override
public void processMessage(String topic, byte[] message) { public void processMessage(String topic, byte[] message) {
try {
Event event = ProtobufConvert.convertIgnition(message); Event event = ProtobufConvert.convertIgnition(message);
if (event == null) { if (event == null) {
return; return;
} }
smartDeviceStatusService.saveEvent(event); smartDeviceStatusService.saveEvent(event);
} catch (Exception e) {
e.printStackTrace();
log.info("topic{}消费异常", topic);
}
} }
} }
...@@ -19,11 +19,16 @@ public class LeaveHomeFlagConsumer extends MessageReceiver { ...@@ -19,11 +19,16 @@ public class LeaveHomeFlagConsumer extends MessageReceiver {
@Override @Override
public void processMessage(String topic, byte[] message) { public void processMessage(String topic, byte[] message) {
log.info("topic{}开始消费",topic); try {
log.info("topic{}开始消费", topic);
Event event = ProtobufConvert.convertLeaveHome(message); Event event = ProtobufConvert.convertLeaveHome(message);
if (event == null) { if (event == null) {
return; return;
} }
smartDeviceStatusService.saveEvent(event); smartDeviceStatusService.saveEvent(event);
}catch (Exception e){
e.printStackTrace();
log.info("topic{}消费异常",topic);
}
} }
} }
...@@ -19,8 +19,13 @@ public class OrderIssueConsumer extends MessageReceiver { ...@@ -19,8 +19,13 @@ public class OrderIssueConsumer extends MessageReceiver {
@Override @Override
public void processMessage(String topic, byte[] message) { public void processMessage(String topic, byte[] message) {
try {
String data = new String(message); String data = new String(message);
log.info("开始消费----------{}",data); log.info("开始消费----------{}", data);
orderIssueService.processMessage(data); orderIssueService.processMessage(data);
} catch (Exception e) {
e.printStackTrace();
log.info("topic{}消费异常", topic);
}
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!