class DataStorageDispatch {

    private final CommonDataQueue commonDataQueue;
    private final WarehouseWorkerPool workerPool;
    private final List<AbstractHistoryDataStorage> historyDataStorages;
    private final List<AbstractRealTimeDataStorage> realTimeDataStorages;

    public DataStorageDispatch(CommonDataQueue commonDataQueue,
                               WarehouseWorkerPool workerPool,
                               List<AbstractHistoryDataStorage> historyDataStorages,
                               List<AbstractRealTimeDataStorage> realTimeDataStorages) {
        this.commonDataQueue = commonDataQueue;
        this.workerPool = workerPool;
        this.historyDataStorages = historyDataStorages;
        this.realTimeDataStorages = realTimeDataStorages;
        startStoragePersistentData();
        startStorageRealTimeData();
    }

    private void startStorageRealTimeData() {<FILL_FUNCTION_BODY>}

    protected void startStoragePersistentData() {
        Runnable runnable = () -> {
            Thread.currentThread().setName("warehouse-persistent-data-storage");
            if (historyDataStorages != null && historyDataStorages.size() > 1) {
                historyDataStorages.removeIf(item -> item instanceof HistoryJpaDatabaseDataStorage);
            }
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    CollectRep.MetricsData metricsData = commonDataQueue.pollMetricsDataToPersistentStorage();
                    if (metricsData != null && historyDataStorages != null) {
                        for (AbstractHistoryDataStorage historyDataStorage : historyDataStorages) {
                            historyDataStorage.saveData(metricsData);
                        }
                    }
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
        };
        workerPool.executeJob(runnable);
    }


}

        Runnable runnable = () -> {
            Thread.currentThread().setName("warehouse-realtime-data-storage");
            if (realTimeDataStorages != null && realTimeDataStorages.size() > 1) {
                realTimeDataStorages.removeIf(item -> item instanceof RealTimeMemoryDataStorage);
            }
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    CollectRep.MetricsData metricsData = commonDataQueue.pollMetricsDataToRealTimeStorage();
                    if (metricsData != null && realTimeDataStorages != null) {
                        for (AbstractRealTimeDataStorage realTimeDataStorage : realTimeDataStorages) {
                            realTimeDataStorage.saveData(metricsData);
                        }
                    }
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
        };
        workerPool.executeJob(runnable);
    
<no_super_class>