Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty HttpClient & ContentExchange

Hi,

On Tue, Mar 13, 2012 at 03:08, Mohammad Ziaul Ahsan <zia7770@xxxxxxxxx> wrote:
>
> Hi All. I hope I am on the correct place to ask about Jetty HttpClient and
> ContentExchange.
>
> I would like to ask you the following questions to see if my understanding
> is correct or not:
> 1) According to this API, shall I set the connector type as bellow?
>
> a.	for asynchronous mode,
> client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
>
> b.	for synchronous mode,
> client.setConnectorType(HttpClient.CONNECTOR_SOCKET);

Correct, although it's not exactly "synchronous", but "blocking"/"non-blocking".

> 2) As it is said in this tutorial “Since HttpClient does not have any
> settings related to a particular address, it can be used to exchange
> requests/responses with several HTTP servers. You normally need one
> HttpClient instance for all your needs, even if you plan to connect to
> multiple HTTP servers.”
>
> Based on the above lines, can I choose singleton pattern?

You do not have to. Just create one instance only of the HttpClient,
and pass it where needed.
Singletons are old-fashioned.

> 3) My application will have 60 requests per min. on average. Will the
> following configuration be sufficient?
>
> client.setMaxConnectionsPerAddress(60); // max 60 concurrent connections
> to every address
> client.setThreadPool(new QueuedThreadPool(60)); // max 60 threads

Difficult to say, it depends on how much time each request takes to complete.

> 4) Do I have to create a new instance of ContentExchange for each request?

Yes.

> I will have at most 20 URLs. As I said before there might be 60 requests per
> minute from among those 20 URLs.

Fine.

Simon
--
http://cometd.org
http://intalio.com
http://bordet.blogspot.com
----
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


Back to the top