Closed jrumbinas closed 5 years ago
I don't understand. We run netty examples from the command line and they work fine.
cd examples ./run_examples -h \<server hostname> -netty AsyncPutGet
NettyEventLoop != NioEventLoop
Sorry, I misread. NioEventLoop also works fine from the command line:
./run_examples -h \<server hostname> AsyncPutGet
If -netty is not specified, NioEventLoop is used.
Ok, the problem is that we're using Spring exit hooks to close aerospike connections. These hooks are triggered once the main thread exits and there are no more user threads running. The problem is that the second part is never satisfied when NioEventLoop
is used.
It would be nice to have a configurable option.
You can try setting thread.setDaemon(true);
in a custom build to see if that works for your case. Note that active transactions in the event loop will not complete if the event loop is defined as a daemon thread and the application exits.
This also did the trick:
var threadFactory = new DefaultThreadFactory("aerospike.netty.nio-events", true);
var group = new NioEventLoopGroup(eventLoopSize, threadFactory);
return new NettyEventLoops(eventPolicy, group);
Nonetheless, it would still be nice to customize thread names and daemon-ness. I would be happy to submit a pull request if that works for you.
Go ahead and submit a pull request.
NioEventLoop
is preventing normal Java application exit. Which makes Aerospike incompatible with comman line applications.