Coder Social home page Coder Social logo

Comments (3)

sveryovka avatar sveryovka commented on August 18, 2024

Any updates on this topic?

from ninja.

raphaelbauer avatar raphaelbauer commented on August 18, 2024

Docu is not yet there, but the integration test has a class that can serve as an example:
https://github.com/ninjaframework/ninja/blob/develop/ninja-servlet-integration-test/src/main/java/controllers/AsyncController.java

Please feel free to add any documentation. Ninja is a community project and all help is well appreciated :)

from ninja.

davidgiga1993 avatar davidgiga1993 commented on August 18, 2024

I just did some testing with async for the first time in ninja and noticed the following:
I need to call context.handleAsync() before returning Results.async(); for it to work, otherwise the client gets an empty http reply immediately (before I called returnResultAsync).
Is this the expected behavior? I saw that handleAsync() is called internally as well when calling retrunResultAsync so I'm not sure if this is the correct usage.

Update:
I'm also getting some IllegalStateException: s=IDLE i=true a=NOT_ASYNC when processing some requests although the client is still waiting for a reply (tcp connection not closed).

A bit of background information: For some endpoints I need to limit the number of parallel executions without blocking the threads. My idea was to put the requests into a queue and return Results.async(). A single worker thread then processes the queue and returns the result with context.returnResultAsync.
This seems to work for 70% of the requests, but for the others I get the exception mentioned above when calling returnResultAsync.

Any idea?

from ninja.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.