Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous processing in JRuby-Rack? #119

Open
kidlab opened this issue Sep 12, 2012 · 7 comments
Open

Asynchronous processing in JRuby-Rack? #119

kidlab opened this issue Sep 12, 2012 · 7 comments
Milestone

Comments

@kidlab
Copy link

kidlab commented Sep 12, 2012

Does JRuby-Rack support asynchronous processing as in Java Servlet 3.0 API ?

As I know, we can create an async. servlet (http://developerlife.com/tutorials/?p=1437). Is there anyway we can do that with JRuby-Rack?

Thanks.

This issue seems to be lacking activity, you can change that by posting a bounty.

@kares
Copy link
Member

kares commented Sep 12, 2012

Hi Man, I just realized it's really not possible with JRuby-Rack to do right now due the way how we handle responses.

It's doable but the "main" problem (at least for me) is how to do it - see there's no Rack standard way of returning an async response, I've seen catch(:async) / throw(:async) or returning negative status responses. I'll try to think of something but can not promise you when I'll get into it. Also it would be perfect to align this somehow with Rails 4.0 ActionController::Live since it would be a perfect fit, unfortunately Thread logic seemed hard-coded last time I've checked for streamed responses thus it might be a long run ...

@kidlab
Copy link
Author

kidlab commented Sep 13, 2012

I have took a look at https://github.com/matadon/mizuno/blob/master/lib/mizuno/rack_servlet.rb. It's also using a "hacking-way" (catch :async) but it seems to integrate better with servlet container.

@kares
Copy link
Member

kares commented Sep 13, 2012

You're right but it's a good fit, it's only unfortunate that it might break a Rack middleware or two.
I thing I "hack" something quite similar into JRuby-Rack. Currently it requires you to write a custom servlet (or filter) to use it with JRuby-Rack (note that Mizuno does not use JRuby-Rack and even uses different env names for the servlet objects). Although it should be easy to write (in Ruby) and configure such servlet for Trinidad (which uses JRuby-Rack).

@kidlab
Copy link
Author

kidlab commented Sep 19, 2012

Can I extend https://github.com/jruby/jruby-rack/blob/master/src/main/java/org/jruby/rack/RackServlet.java with asyncSupported then configure to use it in web.xml? It sounds crazy?

@kares
Copy link
Member

kares commented Sep 21, 2012

I'm sorry for mis-guiding you that won't be enough for JRuby-Rack since you need to dig deeper the source to find the response handling code (as opposed to mizuno's response handling in the servlet). Here's an old attempt I did but gave up due some middleware issuers it has been rebased to match the current master thus do not expet it to work but it shall show you where to get started (hope it helps): kares@2f3a8b0 (async-support branch of my fork)

@jheintz
Copy link

jheintz commented Sep 25, 2012

Me too! I found this issue while search for jruby/rails async servlet integration. I'm not sure that I can do anything to help, but getting async support for long file upload/downloads in our app will be very good for our thread count and memory use.

@grinser
Copy link

grinser commented Oct 1, 2012

I'm building an API with the wonderful Grape framework that pushes requests to a message queue and sends back responses from the queue using the AMQP gem. The AMQP gem does requests asynchronously, hence the only working solution I found using JRuby was Mizuno.
Therefore it would be awesome if you could include async support in jruby-rack soon somehow.

@kares kares added this to the 1.2.0 milestone Aug 22, 2014
@kares kares mentioned this issue Nov 17, 2015
34 tasks
@headius headius modified the milestones: 1.2.0, 1.2.1 May 23, 2024
@headius headius modified the milestones: 1.2.1, 1.2.2, 1.2.3 Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants