Forums > Java

HTTP requests in mxj – slow slow.

February 26, 2010 | 2:04 am

Hey there- i’m using a set of java libraries that does a bunch of HTTP requests and max seems to sort of ‘stutter’ each time that it attempts to complete the http request.
or, if i try to do constant http streaming, i get the spinny wheel for awhile until it finishes.
any ideas why this might be?
thanks y’all.
brian


February 26, 2010 | 3:48 am

unless you do something special, (or the library you’re using does it for you), max’ main thread will wait until your method returns. try putting the request into a second thread and using a callback to alert max when it’s done.


February 26, 2010 | 5:11 am

very helpful, thank you- it looks like some sections of WritingMaxExternalsInJava.pdf might be what Im looking for. I will have to poke at it later, will have to think about it a bit. I wonder if MaxQelem would give me what I need, or if I should just create a new Thread(), public void run(){} etc. Also, not totally sure how to perform a callback in the manner by which you’re referring.


February 26, 2010 | 8:48 pm

Qelem won’t do what you need… my understanding (i’ve never actually had reason to use it myself) is that it will just shunt your slow process to the main thread. That may be all that’s required for something that will take a few milliseconds, but an HTTP request is likely to take several seconds. I would start a new Java thread as demonstrated in the manual.

As the manual also demonstrates, for simple things, you don’t really need a to use a callback function (their example just calls the MaxObject.outlet() from therun() method). If you do find you need or want one, MXJ’s Callback object makes it pretty easy.


Viewing 4 posts - 1 through 4 (of 4 total)