HTTP requests in mxj – slow slow.

Feb 26, 2010 at 2:04am

HTTP requests in mxj – slow slow.

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

#48786
Feb 26, 2010 at 3:48am

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.

#175341
Feb 26, 2010 at 5:11am

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.

#175342
Feb 26, 2010 at 8:48pm

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.

#175343

You must be logged in to reply to this topic.