diff --git a/setup/default.xml b/setup/default.xml index 6bab81401ce..6fdfb2a956b 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -29,6 +29,8 @@ https://www.traccar.org/analytics/ + true + true diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 67fd02f7596..30e6ca71398 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -391,7 +391,7 @@ public static void init(String[] arguments) throws Exception { driversManager = new DriversManager(dataManager); - commandsManager = new CommandsManager(dataManager); + commandsManager = new CommandsManager(dataManager, config.getBoolean("commands.queueing")); statisticsManager = new StatisticsManager(); diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java index 9ceb995ef58..8ddced5f72e 100644 --- a/src/org/traccar/database/CommandsManager.java +++ b/src/org/traccar/database/CommandsManager.java @@ -37,8 +37,11 @@ public class CommandsManager extends ExtendedObjectManager { private final Map> deviceQueues = new ConcurrentHashMap<>(); - public CommandsManager(DataManager dataManager) { + private boolean queueing; + + public CommandsManager(DataManager dataManager, boolean queueing) { super(dataManager, Command.class); + this.queueing = queueing; } public boolean checkDeviceCommand(long deviceId, long commandId) { @@ -70,6 +73,8 @@ public boolean sendCommand(Command command) throws Exception { ActiveDevice activeDevice = Context.getConnectionManager().getActiveDevice(deviceId); if (activeDevice != null) { activeDevice.sendCommand(command); + } else if (!queueing) { + throw new RuntimeException("Device is not online"); } else { getDeviceQueue(deviceId).add(command); return false;