Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run async / non-blocking MySQL queries in Play framework?

Just starting out on Play. The documentation talks about how Play can be run asynchronously.

But how to run MySQL queries when running Play asynchronously? Normal MySQL queries are blocking, right? So that wouldn't work.

Node.js has its own non-blocking MySQL clients just for this purpose, but I can't find anything similar for Play.

How do you run MySQL queries within an asynchronous Play application?

like image 482
Continuation Avatar asked Dec 26 '11 03:12

Continuation


1 Answers

Play Jobs are executed in a separate thread and release the main http thread. The main http thread is then started where it left off when the Job (wrapped in a Promise object) returns after completing.

So, the main http thread is not held up, and can be made available for handling other incoming http requests.

like image 131
Codemwnci Avatar answered Oct 21 '22 06:10

Codemwnci