Setting connection timeout in RestEASY -
jboss tells us
http://docs.jboss.org/seam/3/rest/latest/reference/en-us/html/rest.client.html
that set timeout resteasy clientrequest must create custom clientexecutor, call deprecated static methods on connmanagerparams. seems rather hokey. there better way? resteasy 2.3.6.
here clean working solution :-)
@singleton public class resteasyconfig { @inject @myconfig private integer httpclientmaxconnectionsperroute; @inject @myconfig private integer httpclienttimeoutmillis; @inject @myconfig private integer httpclientmaxtotalconnections; @produces private clientexecutor clientexecutor; @postconstruct public void createexecutor() { final basichttpparams params = new basichttpparams(); httpconnectionparams.setconnectiontimeout(params, this.httpclienttimeoutmillis); final schemeregistry schemeregistry = new schemeregistry(); schemeregistry.register(new scheme("http", 80, plainsocketfactory.getsocketfactory())); final threadsafeclientconnmanager connmanager = new threadsafeclientconnmanager(schemeregistry); connmanager.setdefaultmaxperroute(this.httpclientmaxconnectionsperroute); connmanager.setmaxtotal(this.httpclientmaxtotalconnections); final httpclient httpclient = new defaulthttpclient(connmanager, params); this.clientexecutor = new apachehttpclient4executor(httpclient); } }
Comments
Post a Comment