Skip to content

Commit

Permalink
vertx cleans timers, http clients and bus handlers created in the ver…
Browse files Browse the repository at this point in the history
…ticle automatically
  • Loading branch information
tsegismont committed Jun 26, 2015
1 parent c64bf9f commit 3d02cea
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class MetricsSender extends AbstractVerticle {
private final List<SingleMetric> queue;

private HttpClient httpClient;
private long timerId;
private long sendTime;

public MetricsSender(Configuration configuration) {
Expand Down Expand Up @@ -91,7 +90,7 @@ public void start(Future<Void> startFuture) throws Exception {
.setKeepAlive(true)
.setTryUseCompression(true);
httpClient = vertx.createHttpClient(httpClientOptions);
timerId = vertx.setPeriodic(MILLISECONDS.convert(batchDelay, SECONDS), this::flushIfIdle);
vertx.setPeriodic(MILLISECONDS.convert(batchDelay, SECONDS), this::flushIfIdle);
sendTime = System.nanoTime();
vertx.eventBus().registerDefaultCodec(SingleMetric.class, new SingleMetricCodec());
vertx.eventBus().localConsumer(METRIC_ADDRESS, this::handleMetric)
Expand Down Expand Up @@ -148,12 +147,6 @@ private void flushIfIdle(Long timerId) {
}
}

@Override
public void stop() throws Exception {
vertx.cancelTimer(timerId);
httpClient.close();
}

public static class SingleMetricCodec implements MessageCodec<SingleMetric, SingleMetric> {
@Override
public void encodeToWire(Buffer buffer, SingleMetric singleMetric) {
Expand Down

0 comments on commit 3d02cea

Please sign in to comment.