-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Milestone
Description
Quarkus Version: 0.28.1
Configuration
(application.properties):
...
quarkus.vertx.cluster.clustered=true
...
Console error message
...
0:36:26.633 INFO [main] [null:-1,null()] Beginning quarkus augmentation
10:36:27.398 INFO [main] [null:-1,null()] Quarkus augmentation completed in 765ms
java.lang.IllegalArgumentException: Please use Vertx.clusteredVertx() to create a clustered Vert.x instance
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:38)
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:32)
at io.vertx.core.Vertx.vertx(Vertx.java:85)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:105)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:87)
at io.quarkus.deployment.steps.VertxCoreProcessor$buildWeb3.deploy_0(VertxCoreProcessor$buildWeb3.zig:71)
at io.quarkus.deployment.steps.VertxCoreProcessor$buildWeb3.deploy(VertxCoreProcessor$buildWeb3.zig:96)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:89)
at io.quarkus.runtime.Application.start(Application.java:94)
at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:143)
at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:176)
at io.quarkus.dev.DevModeMain.start(DevModeMain.java:94)
at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
10:36:27.644 ERROR [main] [io.quarkus.dev.DevModeMain:187,doStart()] Failed to start Quarkus: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:185)
at io.quarkus.runtime.Application.start(Application.java:94)
at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:143)
at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:176)
at io.quarkus.dev.DevModeMain.start(DevModeMain.java:94)
at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: java.lang.IllegalArgumentException: Please use Vertx.clusteredVertx() to create a clustered Vert.x instance
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:38)
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:32)
at io.vertx.core.Vertx.vertx(Vertx.java:85)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:105)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:87)
at io.quarkus.deployment.steps.VertxCoreProcessor$buildWeb3.deploy_0(VertxCoreProcessor$buildWeb3.zig:71)
at io.quarkus.deployment.steps.VertxCoreProcessor$buildWeb3.deploy(VertxCoreProcessor$buildWeb3.zig:96)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:89)
... 5 more
...
To reproduce
@Path("/vertx")
public class VertxResource {
@Inject
EventBus eb;
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/echo/{input}")
public CompletionStage<JsonObject> echo(@PathParam("input") String input) {
return eb.<String>request("eb.echo", input).<JsonObject>handle((result, err) -> {
JsonObject respObj;
if (err != null) {
respObj = Json.createObjectBuilder().add("error", err.getCause().toString()).build();
} else {
respObj = Json.createObjectBuilder().add("result", result.body()).build();
}
return respObj;
});
}
}
@ApplicationScoped
public class VertxService {
@ConsumeEvent(value = "eb.echo", blocking = false)
public String echo(String input) {
String dateStr = ZonedDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
return "<echo> process at " + dateStr + " and your input \'" + input + "\'";
}
}
Additional context
It maybe a bug at class: io.quarkus.vertx.core.runtime.VertxCoreRecorder
method: "initializeWeb(VertxConfiguration conf) "
It should be add condition " if (options.getEventBusOptions().isClustered()) {"
work like method "initialize(VertxConfiguration conf) "
...
@Recorder
public class VertxCoreRecorder {
...
public static void initializeWeb(VertxConfiguration conf) {
if (webVertx != null) {
} else if (conf == null) {
webVertx = Vertx.vertx();
} else {
VertxOptions options = convertToVertxOptions(conf);
webVertx = Vertx.vertx(options);
}
}
public static Vertx initialize(VertxConfiguration conf) {
if (conf == null) {
return Vertx.vertx();
}
VertxOptions options = convertToVertxOptions(conf);
if (!conf.useAsyncDNS) {
System.setProperty("vertx.disableDnsResolver", "true");
}
if (options.getEventBusOptions().isClustered()) {
CompletableFuture<Vertx> latch = new CompletableFuture<>();
Vertx.clusteredVertx(options, ar -> {
if (ar.failed()) {
latch.completeExceptionally(ar.cause());
} else {
latch.complete(ar.result());
}
});
return latch.join();
} else {
return Vertx.vertx(options);
}
}
private static VertxOptions convertToVertxOptions(VertxConfiguration conf) {
VertxOptions options = new VertxOptions();
// Order matters, as the cluster options modifies the event bus options.
setEventBusOptions(conf, options);
initializeClusterOptions(conf, options);
String fileCacheDir = System.getProperty(CACHE_DIR_BASE_PROP_NAME,
System.getProperty("java.io.tmpdir", ".") + File.separator + "vertx-cache");
options.setFileSystemOptions(new FileSystemOptions()
.setFileCachingEnabled(conf.caching)
.setFileCacheDir(fileCacheDir)
.setClassPathResolvingEnabled(conf.classpathResolving));
options.setWorkerPoolSize(conf.workerPoolSize);
options.setInternalBlockingPoolSize(conf.internalBlockingPoolSize);
options.setBlockedThreadCheckInterval(conf.warningExceptionTime.toMillis());
if (conf.eventLoopsPoolSize.isPresent()) {
options.setEventLoopPoolSize(conf.eventLoopsPoolSize.getAsInt());
} else {
options.setEventLoopPoolSize(calculateDefaultIOThreads());
}
Optional<Duration> maxEventLoopExecuteTime = conf.maxEventLoopExecuteTime;
if (maxEventLoopExecuteTime.isPresent()) {
options.setMaxEventLoopExecuteTime(maxEventLoopExecuteTime.get().toMillis());
options.setMaxEventLoopExecuteTimeUnit(TimeUnit.MILLISECONDS);
}
Optional<Duration> maxWorkerExecuteTime = conf.maxWorkerExecuteTime;
if (maxWorkerExecuteTime.isPresent()) {
options.setMaxWorkerExecuteTime(maxWorkerExecuteTime.get().toMillis());
options.setMaxWorkerExecuteTimeUnit(TimeUnit.MILLISECONDS);
}
options.setWarningExceptionTime(conf.warningExceptionTime.toNanos());
return options;
}
...