Files
iot-dc3/dc3-common/dc3-common-mqtt
Vickey 27bcf1383b fix: address code review — security, thread safety, performance, and null safety
Security (CRITICAL):
- KeyUtil: read JWT signing key from DC3_SECURITY_KEY env/property
- UserPasswordServiceImpl: read default password from DC3_SECURITY_DEFAULT_PASSWORD env
- KeyLoader: read OPC-UA keystore password from OPCUA_KEYSTORE_PASSWORD env
- WebFilterConfig: return 401 on malformed X-Auth-User header
- AlgorithmConstant: document deprecated hardcoded constants

Thread safety (HIGH):
- Fix TOCTOU races in 4 driver connectors (computeIfAbsent)
- Fix PlcS7 lock leak, OpcUa connect timeout (5s)
- CoapClientManager: synchronize setURI to prevent URI race
- PointValueJob, MqttScheduleJob: add @DisallowConcurrentExecution
- SystemHealthServiceImpl: preserve interrupt flag
- WindowSampleBuffer: local AtomicInteger → int

Performance (MEDIUM):
- EntityStateExpiryScanner: batch alarm saves (saveBatch)
- ImportDeviceServiceImpl: batch config saves
- ResourceRegistrySyncServiceImpl: batch-load nodes, eliminate N+1 COUNTs
- DriverSenderServiceImpl: debug-gate hot-path logging
- PointServiceImpl: stream().count() → size()

Null safety (LOW):
- RegexUtil: null guards on isName/isPhone/isMail/isPassword/isHost
- HostUtil: null-check getNetworkInterfaces() return
- TimeUtil: log parse failures instead of silent null

Infrastructure:
- Add spring-boot-starter-cache + @EnableCaching CacheConfig
- Replace embedded modbus4j/plc-s7 jars with external Maven dependencies
- Add dc3-driver-modbus-rtu module
2026-05-26 08:40:25 +08:00
..
2026-05-26 00:30:11 +08:00

DC3 Common MQTT

Overview

dc3-common-mqtt is the shared MQTT client configuration module of the IoT DC3 platform. It provides auto-configuration for MQTT connection, message handling, and topic subscription used by the MQTT driver and any service requiring MQTT connectivity.

Module Information

  • Group ID: io.github.pnoker
  • Artifact ID: dc3-common-mqtt
  • Version: 2026.5.22

Key Components

Component Purpose
MqttConfig Auto-configures MqttClient based on environment properties
MqttEnvironmentConfig Binds MQTT connection properties from YAML
MqttUtil Utility methods for publishing/subscribing MQTT messages
MqttInitRunner Startup runner for MQTT connection initialization

Configuration Properties

Configure in application*.yml:

mqtt:
  host: ${MQTT_HOST:dc3-emqx}
  port: ${MQTT_PORT:1883}
  username: ${MQTT_USERNAME:dc3}
  password: ${MQTT_PASSWORD:dc3dc3dc3}
  qos: 1
  client-id: ${spring.application.name}

Usage

This module is activated when the mqtt profile is included or MQTT-related auto-configuration is on the classpath. The MQTT driver (dc3-driver-mqtt) depends on this module as its primary integration layer.

Build Instructions

mvn -s ../../.mvn/settings.xml clean package
  • dc3-driver-mqtt — Primary consumer of this module
  • For MQTT broker: use EMQX via podman compose -f dc3/docker-compose-optional.yml up -d (port 31883)

License

Copyright 2016-present the IoT DC3 original author or authors.

Licensed under the GNU Affero General Public License v3.0 (AGPL 3.0)