package com.ld.igds.protocol.iot.height.server;
|
|
import com.ld.igds.protocol.iot.height.analysis.AnalysisService;
|
import com.ld.igds.protocol.iot.height.analysis.builder.ReMessageBuilder;
|
import com.ld.io.api.IoMsgConsumer;
|
import com.ld.io.api.IoSession;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
/**
|
*/
|
@Service
|
@Slf4j
|
public class IotMessageConsumer implements IoMsgConsumer {
|
|
|
|
// @Autowired
|
// private PublisherControl publisherControl;
|
@Autowired
|
private AnalysisService analysisService;
|
|
/**
|
* 队列里面处理消息
|
* @param ioSession
|
* @param bytes
|
*/
|
public void consume(IoSession ioSession, byte[] bytes) {
|
if (null == bytes) {
|
log.error("Reply bytes is null");
|
return;
|
}
|
try {
|
String message = new String(bytes, ReMessageBuilder.CHARSET);
|
message = message.substring(ReMessageBuilder.PREFIX.length());
|
log.info("收到网关消息:" + message);
|
analysisService.analysis(ioSession.getBusinessKey(),message);
|
}catch (Exception e){
|
log.error(e.getMessage(),e);
|
}
|
}
|
}
|