I'm writing a Java client to connect to Cassandra. When I deliberately kill Cassandra server, the client's JVM immediately exits with 143.
It's the same result when doing the same experiment on Apache kafka. I quickly grep and see neither the Java driver nor Netty calls System.exit.
Is killing the JVM done somewhere in the Cassandra or the Kafka Java driver? If so, is there a particular reason why?(JDBC driver throws a SQLException in that situation which might be better.)
If JVM shutdown is unavoidable and I want my service keep running, I would isolate the cassandra/kafka clients in another JVM, e.g. using Akka remote. Is it a good idea?
P.S. I'm using cassandra-driver-core:3.0.0-rc1
and kafka-clients:0.9.0.0
[EDIT]
I knew addShutdownHook
, but that's not what I'm looking for, because JVM is going to die anyway. My application connects to Cassandra and provides other services. I don't want the application dies because the connection to Cassandra lost.
[EDIT] Also I'm curious about two more things than adding a hook:
- Why the JVM aborts. Is it coming from Cassandra java driver?
- Is a good idea to put the Cassandra-client logic in another JVM like, for example, Akka remote.