| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | |
| | | @Slf4j |
| | | @Slf4j(topic = "mqttCar") |
| | | public class MessageCallback implements MqttCallback { |
| | | |
| | | private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | |
| | | @Override //消息发布者消息发布完成产生的回调 |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | log.info("deliveryComplete---------" + token.isComplete()); |
| | | log.debug("deliveryComplete---------" + token.isComplete()); |
| | | int messageId = token.getMessageId(); |
| | | String[] topics = token.getTopics(); |
| | | String clientId = token.getClient().getClientId(); |
| | |
| | | topicStr = topicStr + topic + ","; |
| | | } |
| | | topicStr = topicStr.substring(0, topicStr.length() - 1); |
| | | log.info("消息发布完成,messageId="+messageId+",topics="+topicStr+",clientId="+clientId); |
| | | log.debug("消息发布完成,messageId="+messageId+",topics="+topicStr+",clientId="+clientId); |
| | | } |
| | | |
| | | @Override//消息订阅者收到消息后触发的回调 |