Vert.x aerospike client to use context-bound event loop

Standard java aerospike client’s methods have overloads allowing to provide EventLoop as an argument. When running in vert.x that client is not aware of context-bounded event loop and just fallbacks to if (eventLoop == null) { eventLoop =; } which could(and likely does) causes context switching/level of concurrency which in turn affects performance (it’s still in theory, but I want to prove it), because there is no guarantee that aerospike requests will run on the same event loop as coming http request according to Vert.x Multi Reactor pattern. Open source aerospike clients like vertx-aerospike-client also have such a disadvantage. Using vert.x there is no way(at least I’m not aware of) to retrieve context-bounded event loop and pass it to aerospike client.

Vert.x has method to retrieve Context Vertx.currentContext() but retrieving EventLoop is not available.

Any ideas?

One possible solution is to create a map (usually IdentityHashMap) of all Vertx context(s) to Aerospike EventLoop(s). Then, EventLoop can be looked up by the current context.

If Vertx supports user-defined tags on the context, then setting this tag to EventLoop would be another alternative.

Sounds like a working solution, thanks. I’ll try it out.