队列名称方法化
This commit is contained in:
parent
1e15debe49
commit
5fd5dc316e
|
@ -90,7 +90,7 @@ public class Redis2DBPersistenceService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tableName = DEFAULT_DATA_TABLE + deviceId;
|
tableName = DEFAULT_DATA_TABLE + deviceId;
|
||||||
queueName = Queues.DEVICE_EVENTS + (deviceId % 10);
|
queueName = Queues.getDeviceEventsQueue(deviceId);
|
||||||
persistenceHandler = persistenceHandlerMap.get(modbusDeviceProductCode);
|
persistenceHandler = persistenceHandlerMap.get(modbusDeviceProductCode);
|
||||||
existsTableList = this.jdbcTemplate.queryForList(StringUtils.replace(EXISTS_TABLE_SQL, "$TableName$", tableName));
|
existsTableList = this.jdbcTemplate.queryForList(StringUtils.replace(EXISTS_TABLE_SQL, "$TableName$", tableName));
|
||||||
if (ObjectUtils.isEmpty(existsTableList)
|
if (ObjectUtils.isEmpty(existsTableList)
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class DynamicRabbitListener implements ApplicationRunner {
|
||||||
public void run(ApplicationArguments args) {
|
public void run(ApplicationArguments args) {
|
||||||
// this.composeListener.addBatchMessageListener(new ModbusMessageBackupListener());
|
// this.composeListener.addBatchMessageListener(new ModbusMessageBackupListener());
|
||||||
this.composeListener.addBatchMessageListener(new ModbusMessagePersistListener());
|
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.addEventListener(Queues.DEVICE_EVENTS + index);
|
||||||
this.addCollectDataListener(Queues.MODBUS_COLLECT_DATA + index);
|
this.addCollectDataListener(Queues.MODBUS_COLLECT_DATA + index);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,11 @@ package com.isu.gaswellwatch.modbus.data.listener;
|
||||||
* 2024/11/26 12:37
|
* 2024/11/26 12:37
|
||||||
*/
|
*/
|
||||||
public final class Queues {
|
public final class Queues {
|
||||||
|
public static final int QUEUE_PARTITION = 10;
|
||||||
public static final String DEVICE_EVENTS = "/device/events/";
|
public static final String DEVICE_EVENTS = "/device/events/";
|
||||||
public static final String MODBUS_COLLECT_DATA = "/modbus/collect/";
|
public static final String MODBUS_COLLECT_DATA = "/modbus/collect/";
|
||||||
|
|
||||||
|
public static String getDeviceEventsQueue(Long deviceId) {
|
||||||
|
return DEVICE_EVENTS + (deviceId % QUEUE_PARTITION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue