diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-04-28 23:40:54 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-28 23:40:54 +1200 |
commit | d5db101a0adaea03d0aa031911752d2e4353c9cf (patch) | |
tree | 7dfdbb7590af471943d89fb7c2109b56c0bb8837 | |
parent | c763c6c688a2148e46c951c9fc33c09e640bcd9d (diff) | |
parent | 4086a60931b85717af7ce6e52a1945fab762dc8c (diff) | |
download | trackermap-server-d5db101a0adaea03d0aa031911752d2e4353c9cf.tar.gz trackermap-server-d5db101a0adaea03d0aa031911752d2e4353c9cf.tar.bz2 trackermap-server-d5db101a0adaea03d0aa031911752d2e4353c9cf.zip |
Merge pull request #3862 from Abyss777/switch_queueing
Make Commands queueing switchable
-rw-r--r-- | setup/default.xml | 2 | ||||
-rw-r--r-- | src/org/traccar/Context.java | 2 | ||||
-rw-r--r-- | src/org/traccar/database/CommandsManager.java | 7 |
3 files changed, 9 insertions, 2 deletions
diff --git a/setup/default.xml b/setup/default.xml index 6bab81401..6fdfb2a95 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -29,6 +29,8 @@ <entry key='server.statistics'>https://www.traccar.org/analytics/</entry> + <entry key='commands.queueing'>true</entry> + <!-- DATABASE CONFIG --> <entry key='database.ignoreUnknown'>true</entry> diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 67fd02f75..30e6ca713 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -391,7 +391,7 @@ public final class Context { 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 9ceb995ef..8ddced5f7 100644 --- a/src/org/traccar/database/CommandsManager.java +++ b/src/org/traccar/database/CommandsManager.java @@ -37,8 +37,11 @@ public class CommandsManager extends ExtendedObjectManager<Command> { private final Map<Long, Queue<Command>> 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 class CommandsManager extends ExtendedObjectManager<Command> { 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; |