java - Retrieving SQL query execution results asynchronously. -


after quite bit of research decided go ahead , write question may seem redundant here on stack-overflow, i'm asking because i've failed find answer. i've been having fun java nio2 framework has increased scalability of applications tremendously. (we using old-school i/o tpc server/client setup mildly populated emulation servers), , let me tell you. concurrency queen b if know mean.

we're moving using threads answer (in attempt better practices , become more familiar advancing technology). using flat-file storage (text/binary format storage) user-data , have migrated on sql database.

while doing i've noticed there's not problem, waiting on database never fun, , in emulated game-environment waiting database call never fun, when entire game-server waiting. substitute threading. why not execute sql call on thread using thread pool or similar.

the java nio2 completablefuture<k,v> has been huge type of asynchronous event, i've been trying find way use sql calls. figured writing our own version of jdbc used nio2 option seems bit over-kill , take more time , money it's worth. remember we're small emulation community, not large-scale business, want make sure provide quality our users.

i looking jooq seems alright, seems little over-kill. uses completablefuture#supplyasych method example available don't explain in-depth. it's mixed in quote:

there 1 blocking barrier such solutions, , jdbc – hard turn asynchronous api. in fact, few databases support asynchronous query executions.

however, database doesn't need support asynchronous query executions in-order results provided in asynchronous context. if server isn't waiting(and waiting) api results query, that's thing matters here. similar activity can explained using example unity's scripting reference: coroutines.

please not recommend scala.

java nio2 @ low level you.

your "thought bubble" of developing asynchronous version of jdbc problematic 2 reasons:

  • it doesn't fit way transactions implemented above jdbc api layer (i.e. in application code). application handles multiple transactions simultaneously on smaller number of threads going lot more complex. more complex (typically) means less reliable, , that's not want when doing (conventional) database operations.

  • designing asynchronous jdbc api 1 thing, implementing thing entirely. real problem here real work happening in multiple jdbc drivers:

    • some of drivers proprietary.
    • all of drivers talk kind of non-standard "protocol" back-end database (either in jvm or on network connection).
    • those protocols (afaik) synchronous in nature, , proprietary.
    • updating or replacing protocols supports asynchronous modes going entail changing database implementations themselves.

so solution?

well q&a has links projects attempting implement asynchronous database apis: "is asynchronous jdbc call possible?".

i guess, if not satisfied (i.e. progress or apis), start own project. however, liable run same set of design , implementation problems.

the other approach may give on sql , acid entirely, , review of so-called "nosql" databases see if give kind of asynchronous apis , behaviour want.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -