Skip to content

Commit

Permalink
fix(vertx): Fix event duplication during spoon mining
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt committed Jul 15, 2023
1 parent c9c9811 commit 27ab435
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.martinwitt.laughing_train.mining;

import io.github.martinwitt.laughing_train.mining.requests.MineNextProject;
import io.quarkus.logging.Log;
import io.quarkus.runtime.StartupEvent;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
Expand Down Expand Up @@ -47,13 +46,20 @@ void startup(@Observes StartupEvent event) {
vertx.deployVerticle(miningEventConsumer, options))
.onFailure(Throwable::printStackTrace)
.onComplete(v -> System.out.println("All verticles deployed"))
.onSuccess(v -> Log.info("Starting periodic mining"));
.onSuccess(v -> startMining());
vertx.eventBus().addInboundInterceptor(v -> {
System.out.println("Received message: " + v.toString());
v.next();
});
}

private void startMining() {
vertx.setPeriodic(TimeUnit.MINUTES.toMillis(3), TimeUnit.MINUTES.toMillis(25), v -> vertx.eventBus()
.publish("miner", new MineNextProject(QodanaPeriodicMiner.ANALYZER_NAME)));
vertx.setPeriodic(TimeUnit.MINUTES.toMillis(2), TimeUnit.MINUTES.toMillis(10), v -> vertx.eventBus()
.publish("miner", new MineNextProject(SpoonPeriodicMiner.ANALYZER_NAME)));
}

@ApplicationScoped
private static class MiningEventConsumer extends AbstractVerticle {

Expand Down

0 comments on commit 27ab435

Please sign in to comment.