You mean to say this is inefficient? If yes, then what should I do instead
of below?
String responseBody = IOUtils.toString(entity.getContent(), StandardCharsets
.UTF_8);
On Fri, May 13, 2016 at 4:03 AM, Oleg Kalnichevski wrote:
> On Thu, 2016-05-12 at 13:17 -0700, Check Peck wrote:
> > I have a library which is being used by customer and they are passing
> > DataRequest object which has userid, various timeouts and some other
> fields
> > in it. Now I use this DataRequest object to make a URL and then I make an
> > HTTP call using Apache HttpClient and my service returns back a JSON
> > response which I use it to make a DataResponse object and return this
> > DataResponse object back to them.
> >
> > Below is my DataClient class used by customer by passing DataRequest
> object
> > to it.
> >
> > https://gist.github.com/TechGeeky/250be2d9cdef3fa5107a17058a265d4c
> >
> > And here is DataFetcherTask class:
> >
> > https://gist.github.com/TechGeeky/c1b21025e0f81d222b792dedac0a817d
> >
> > Customer within our company will use my library like this as shown below
> by
> > using my factory in their code base -
> >
> > // if they are calling getSyncData() method
> > DataResponse response =
> > DataClientFactory.getInstance().getSyncData(key);
> >
> > // and if they want to call getAsyncData() method
> > Future response =
> > DataClientFactory.getInstance().getAsyncData(key);
> >
> > I am implementing "sync call as async + waiting" since I want to throttle
> > them with the number of threads otherwise they can bombard our service
> > without any control. My library will be used by lot of customers within
> our
> > company and their applications won't ever shutdown, they will keep
> running
> > always. The only thing will happen is their machines will get restarted,
> > that's all.
> >
> > Is this the right way to use Apache HttpClient in production in
> > multithreaded environment? Or there is any better/efficient way?
> >
> > I have to use various timeout values present in my DataRequest class in
> my
> > Apache HttpClient calls so that's why I am creating RequestConfig and
> > using it in my call method. I have simplified the code so that idea gets
> > clear what I am trying to do.
>
> Looks OK for the most part. However I would consider conversion of
> response entity to a string rather inefficient.
>
> Oleg
>
>
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>