public class StartVerticle extends Verticle
{
@Override
public void start(final Future<Void> startFuture)
{
// deploy other verticles
// if something does wrong undeploy
startFuture.setFailure(new IllegalArgumentException("Cannot start"));
}
}
public class StartVerticle extends AbstractVerticle
{
@Override
public void start(final Future<Void> startFuture) throws Exception
{
// deploy other verticles
// if something does wrong undeploy
startFuture.fail(new IllegalArgumentException("Cannot start"));
}
}
public class MyVerticle extends AbstractVerticle
{
public void start(Future<Void> startFuture)
{
// Now deploy some other verticle:
vertx.deployVerticle("force-exception", res -> {
if(res.succeeded())
{
startFuture.complete();
}
else
{
startFuture.fail("After this log message JVM hangs !");
}
});
}
public static void main(final String[] args)
{
final String[] arguments = {"run", "test.MyVerticle"};
Starter.main(arguments);
}
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Assen,
Just to clarify - are you referring to running at the command line?
Could you be a bit more specific about how you're running your application and what you expect to happen?
Hi Tim,
Thanks for your reply.
On Wednesday, July 1, 2015 at 10:47:40 PM UTC+2, Tim Fox wrote:Assen,
Just to clarify - are you referring to running at the command line?
We deploy our application as fat-jar
and run it with java -jar on the command line. But the problem could also be reproduced, if we start our application in the IDE via main-method (see my second post for reproducer)
Could you be a bit more specific about how you're running your application and what you expect to happen?
Expectations
When we start our application (java -jar ...), we would like that the JVM exits, if some application initialization error occur (for instance the application did not found some configuration file). To achieve this, we implemented the async version of the start-Method in our main verticle. On initialization error, we just call startFuture.fail() and expect, that the Vertx framework stops the deployment and exits the JVM
(i.e. there is no more java process in the background and we see immediately the command prompt again :-) )
ObservationsWhen we start our application (java -jar ...) and some application initialization error occur, the JVM does not exit (i.e. it hangs and we do not see the comman prompt again). Investigation with jvisualvm showed us, that there are still event-loop threads in background.
HI Assen,
On 02/07/15 08:20, Assen Todorov wrote:
Hi Tim,
Thanks for your reply.
On Wednesday, July 1, 2015 at 10:47:40 PM UTC+2, Tim Fox wrote:Assen,
Just to clarify - are you referring to running at the command line?
We deploy our application as fat-jar
Are you using Starter as your main class, or are you using your own main class?
and run it with java -jar on the command line. But the problem could also be reproduced, if we start our application in the IDE via main-method (see my second post for reproducer)
Could you be a bit more specific about how you're running your application and what you expect to happen?
Expectations
When we start our application (java -jar ...), we would like that the JVM exits, if some application initialization error occur (for instance the application did not found some configuration file). To achieve this, we implemented the async version of the start-Method in our main verticle. On initialization error, we just call startFuture.fail() and expect, that the Vertx framework stops the deployment and exits the JVM
That's tricky. In general a Vert.x instance can deploy many verticles and if a particular deployment fails stopping the Vert.x instance won't usually be the right thing to do. So we can't do that in the general case, it just wouldn't make sense.
However in the case of a *single* verticle run using Starter, that might be the correct thing to do.
(i.e. there is no more java process in the background and we see immediately the command prompt again :-) )
ObservationsWhen we start our application (java -jar ...) and some application initialization error occur, the JVM does not exit (i.e. it hangs and we do not see the comman prompt again). Investigation with jvisualvm showed us, that there are still event-loop threads in background.
This is deliberate. In Vert.x 2 Vert.x threads were daemon so they would not prevent the JVM from exiting,
Hi Tim,
On Thursday, July 2, 2015 at 1:19:56 PM UTC+2, Tim Fox wrote:HI Assen,
On 02/07/15 08:20, Assen Todorov wrote:
Hi Tim,
Thanks for your reply.
On Wednesday, July 1, 2015 at 10:47:40 PM UTC+2, Tim Fox wrote:Assen,
Just to clarify - are you referring to running at the command line?
We deploy our application as fat-jar
Are you using Starter as your main class, or are you using your own main class?
We are using Starter as main class. The Starter deploys a *single* verticle, which in turn deploys other 4 verticles. We do not use Vert.x in embedded mode.
and run it with java -jar on the command line. But the problem could also be reproduced, if we start our application in the IDE via main-method (see my second post for reproducer)
Could you be a bit more specific about how you're running your application and what you expect to happen?
Expectations
When we start our application (java -jar ...), we would like that the JVM exits, if some application initialization error occur (for instance the application did not found some configuration file). To achieve this, we implemented the async version of the start-Method in our main verticle. On initialization error, we just call startFuture.fail() and expect, that the Vertx framework stops the deployment and exits the JVM
That's tricky. In general a Vert.x instance can deploy many verticles and if a particular deployment fails stopping the Vert.x instance won't usually be the right thing to do. So we can't do that in the general case, it just wouldn't make sense.
However in the case of a *single* verticle run using Starter, that might be the correct thing to do.
IMHO this is our case - *single* verticle run using Starter. But, if the fact matters, that this *single* verticle deploys other verticles, then this could be our problem.