java - How to support batch web api request processing using Spring/Servlets -
we have our web api written in using resteasy. provide support batch requests processing way google batch request processing works.
following approach using currently,
we have filter accepts incoming multipart request. filter creates multiple mock requests , response objects , calls chain.dofilter using these mock requests.
public class batchrequestprocessingfilter extends genericfilterbean { @override public void dofilter(servletrequest req, servletresponse res, filterchain chain) throws ioexception, servletexception { httpservletrequest request = (httpservletrequest)req; mockhttpservletrequest[] mockrequests = batchrequestprocessorutils.parserequest(request); mockhttpservletresponse[] mockresponses = new mockhttpservletresponse[mockrequests.length]; for(int i=0 ; <= mockrequests.length ; i++ ) { chain.dofilter(mockrequests[i], mockresponses[i], chain); } batchrequestprocessingutils.populateresponsefrommockresponses(res, mockresponses); } }
mockhttpservletresponse
class returns dummy outputstream
wraps bytearrayoutputstream
.
batchrequestprocessorutils
parses multipart request , returns mock request wraps actual request returns header specified in split body of actual request body.
i not find existing library supports batch request processing. question that, correct approach support batch request or there standard way should used?
note using tomcat 8.
Comments
Post a Comment