Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
qinjie 2024-12-06 16:11:26 +08:00
commit 7dfdf48309
3 changed files with 7 additions and 2 deletions

View File

@ -90,7 +90,7 @@ public class Redis2DBPersistenceService {
}
}
tableName = DEFAULT_DATA_TABLE + deviceId;
queueName = Queues.DEVICE_EVENTS + (deviceId % 10);
queueName = Queues.getDeviceEventsQueue(deviceId);
persistenceHandler = persistenceHandlerMap.get(modbusDeviceProductCode);
existsTableList = this.jdbcTemplate.queryForList(StringUtils.replace(EXISTS_TABLE_SQL, "$TableName$", tableName));
if (ObjectUtils.isEmpty(existsTableList)

View File

@ -39,7 +39,7 @@ public class DynamicRabbitListener implements ApplicationRunner {
public void run(ApplicationArguments args) {
// this.composeListener.addBatchMessageListener(new ModbusMessageBackupListener());
this.composeListener.addBatchMessageListener(new ModbusMessagePersistListener());
IntStream.range(0, 10).forEach(index -> {
IntStream.range(0, Queues.QUEUE_PARTITION).forEach(index -> {
this.addEventListener(Queues.DEVICE_EVENTS + index);
this.addCollectDataListener(Queues.MODBUS_COLLECT_DATA + index);
});

View File

@ -5,6 +5,11 @@ package com.isu.gaswellwatch.modbus.data.listener;
* 2024/11/26 12:37
*/
public final class Queues {
public static final int QUEUE_PARTITION = 10;
public static final String DEVICE_EVENTS = "/device/events/";
public static final String MODBUS_COLLECT_DATA = "/modbus/collect/";
public static String getDeviceEventsQueue(Long deviceId) {
return DEVICE_EVENTS + (deviceId % QUEUE_PARTITION);
}
}