MqttProperties.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.zhouhong.mqtt.emqt.config;
  2. import lombok.Data;
  3. import org.springframework.boot.context.properties.ConfigurationProperties;
  4. import org.springframework.stereotype.Component;
  5. /**
  6. * description:
  7. * date: 2022/6/16 15:51
  8. * @author: zhouhong
  9. */
  10. @Component
  11. @ConfigurationProperties("mqtt")
  12. @Data
  13. public class MqttProperties {
  14. /**
  15. * 用户名
  16. */
  17. private String username;
  18. /**
  19. * 密码
  20. */
  21. private String password;
  22. /**
  23. * 连接地址
  24. */
  25. private String hostUrl;
  26. /**
  27. * 客户端Id,同一台服务器下,不允许出现重复的客户端id
  28. */
  29. private String clientId;
  30. /**
  31. * 默认连接主题
  32. */
  33. private String topic;
  34. /**
  35. * 超时时间
  36. */
  37. private int timeout;
  38. /**
  39. * 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端
  40. * 发送个消息判断客户端是否在线,但这个方法并没有重连的机制
  41. */
  42. private int keepAlive;
  43. /**
  44. * 设置是否清空session,这里如果设置为false表示服务器会保留客户端的连
  45. * 接记录,这里设置为true表示每次连接到服务器都以新的身份连接
  46. */
  47. private Boolean cleanSession;
  48. /**
  49. * 是否断线重连
  50. */
  51. private Boolean reconnect;
  52. /**
  53. * 连接方式
  54. */
  55. private Integer qos;
  56. }