project-car/cloud-modules/cloud-modules-template/src/main/java/com/template/util/Callback.java

52 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.template.util;
import com.muyu.common.core.domain.Result;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.template.domain.MessageTemplateType;
import com.template.service.TemplateService;
import lombok.extern.log4j.Log4j2;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
/**
* @Authorliuxinyue
* @Packagecom.template.util
* @Projectcloud-server
* @nameCallback
* @Date2024/9/26 15:23
*/
@Log4j2
public class Callback implements MqttCallback{
@Resource
private static TemplateService templateService;
@Override
public void connectionLost(Throwable throwable) {
log.error(throwable.getMessage(),throwable);
}
@Override
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
log.info("收到了来自:"+s+"的消息:{}",new String(mqttMessage.getPayload()));
}
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
log.info("发布消息成功");
}
}