aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notification
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-12-13 15:51:33 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-12-13 15:51:33 -0800
commitbc3b09e48efb9a58d9aef111d4316dcd9c0a7038 (patch)
tree18179346c5838bae1fdabb4007f309aa598c7600 /src/main/java/org/traccar/notification
parentd4f9561b978ea0410acc7a80a42137e13f06c846 (diff)
downloadtrackermap-server-bc3b09e48efb9a58d9aef111d4316dcd9c0a7038.tar.gz
trackermap-server-bc3b09e48efb9a58d9aef111d4316dcd9c0a7038.tar.bz2
trackermap-server-bc3b09e48efb9a58d9aef111d4316dcd9c0a7038.zip
Improve forwarding logging
Diffstat (limited to 'src/main/java/org/traccar/notification')
-rw-r--r--src/main/java/org/traccar/notification/EventForwarder.java28
-rw-r--r--src/main/java/org/traccar/notification/JsonTypeEventForwarder.java18
2 files changed, 21 insertions, 25 deletions
diff --git a/src/main/java/org/traccar/notification/EventForwarder.java b/src/main/java/org/traccar/notification/EventForwarder.java
index c0010ebbd..966bff31d 100644
--- a/src/main/java/org/traccar/notification/EventForwarder.java
+++ b/src/main/java/org/traccar/notification/EventForwarder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package org.traccar.notification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.model.Device;
import org.traccar.model.Event;
@@ -22,13 +24,16 @@ import org.traccar.model.Geofence;
import org.traccar.model.Maintenance;
import org.traccar.model.Position;
-import javax.ws.rs.client.AsyncInvoker;
+import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.InvocationCallback;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-public abstract class EventForwarder {
+public class EventForwarder {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(EventForwarder.class);
private final String url;
private final String header;
@@ -56,7 +61,19 @@ public abstract class EventForwarder {
}
}
- executeRequest(event, position, users, requestBuilder.async());
+ LOGGER.debug("Event forwarding initiated");
+ requestBuilder.async().post(
+ Entity.json(preparePayload(event, position, users)), new InvocationCallback<Object>() {
+ @Override
+ public void completed(Object o) {
+ LOGGER.debug("Event forwarding succeeded");
+ }
+
+ @Override
+ public void failed(Throwable throwable) {
+ LOGGER.warn("Event forwarding failed", throwable);
+ }
+ });
}
protected Map<String, Object> preparePayload(Event event, Position position, Set<Long> users) {
@@ -85,7 +102,4 @@ public abstract class EventForwarder {
return data;
}
- protected abstract void executeRequest(
- Event event, Position position, Set<Long> users, AsyncInvoker invoker);
-
}
diff --git a/src/main/java/org/traccar/notification/JsonTypeEventForwarder.java b/src/main/java/org/traccar/notification/JsonTypeEventForwarder.java
deleted file mode 100644
index 55d926fc8..000000000
--- a/src/main/java/org/traccar/notification/JsonTypeEventForwarder.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.traccar.notification;
-
-import java.util.Set;
-
-import org.traccar.model.Event;
-import org.traccar.model.Position;
-
-import javax.ws.rs.client.AsyncInvoker;
-import javax.ws.rs.client.Entity;
-
-public class JsonTypeEventForwarder extends EventForwarder {
-
- @Override
- protected void executeRequest(Event event, Position position, Set<Long> users, AsyncInvoker invoker) {
- invoker.post(Entity.json(preparePayload(event, position, users)));
- }
-
-}