|
14 | 14 | import org.java_websocket.drafts.Draft;
|
15 | 15 | import org.java_websocket.drafts.Draft_6455;
|
16 | 16 | import org.java_websocket.handshake.ServerHandshake;
|
| 17 | +import org.ops4j.pax.logging.spi.PaxLoggingEvent; |
17 | 18 | import org.slf4j.Logger;
|
18 | 19 | import org.slf4j.LoggerFactory;
|
19 | 20 |
|
|
34 | 35 | class MyWebSocketClient extends WebSocketClient {
|
35 | 36 |
|
36 | 37 | private final static Draft WEBSOCKET_DRAFT = new Draft_6455();
|
37 |
| - private final static int DEFAULT_WAIT_AFTER_CLOSE = 1; // 1 second |
| 38 | + private final static int DEFAULT_WAIT_AFTER_CLOSE = 5; // 1 second |
38 | 39 | private final static int MAX_WAIT_AFTER_CLOSE = 60 * 3; // 3 minutes
|
39 | 40 |
|
40 | 41 | private final Logger log = LoggerFactory.getLogger(MyWebSocketClient.class);
|
@@ -100,14 +101,18 @@ public void onError(Exception ex) {
|
100 | 101 | }
|
101 | 102 |
|
102 | 103 | protected void deactivate() {
|
103 |
| - this.handler.dispose(); |
104 |
| - this.reconnectExecutor.shutdown(); |
105 | 104 | this.close(2000, "Disabled Backend Api Controller");
|
| 105 | + this.handler.dispose(); |
| 106 | + this.reconnectExecutor.shutdownNow(); |
| 107 | + try { |
| 108 | + this.reconnectExecutor.awaitTermination(5, TimeUnit.SECONDS); |
| 109 | + } catch (InterruptedException e) { |
| 110 | + this.log.error("Unable to shutdown: " + e.getMessage()); |
| 111 | + } |
106 | 112 | }
|
107 | 113 |
|
108 |
| - // TODO implmeent log |
109 |
| - protected void sendLog(long timestamp, String level, String source, String message) { |
110 |
| - this.handler.sendLog(timestamp, level, source, message); |
| 114 | + protected void sendLog(PaxLoggingEvent event) { |
| 115 | + this.handler.sendLog(event); |
111 | 116 | }
|
112 | 117 |
|
113 | 118 | /**
|
|
0 commit comments