First of all, I'm not trying to start a flame-war here. I know Jersey sufficiently well, but have hardly used httpclient.
What are the key differences between jersey-client and Apache's httpclient? In what areas is one better than the other? Is there a good comparison chart somewhere? Which one performs better with larger files (say 2048 MB)?
Many thanks for your comments!
These two things probably should not be compared directly. Jersey is a REST-client, featuring full JAX-RS implementation, neat fluent API and a powerfull filter stack. Apache Http Client is a HTTP-client, perfect in managing low-level details like timeouts, complex proxy routes and connection polling. They act on a different levels of your protocol stack. When you're using Jersey there is always some kind of HTTP client backend involved. Given no backend explicitly, Jersey will use
HttpUrlConnection
as a default backend.Jersey with HttpUrlConnection backend example:
Jersey with Apache Http Client backend example:
Please note usage of Handler in the last example. This is a key integration abstraction for Jersey to incorporate and utilize various backends. First example uses
URLConnectionClientHandler
deep under the hood.Speaking about performance and features it makes little sense to compare Apache Http Client with Jersey. One may want to compare different Jersey backends here, as Jersey itself is merely a wrapping API. I'd like to highlight some key differencies between HttpUrlConnection and Apache Http Client based on my own experience:
HttpUrlConnection
HttpUrlConnection
-based implementation is difficult to maintain and extend.Apache Http Client
HttpUrlConnection
. Version 4.1 contains lots of performance enchancements and performs way better than it's counterpartHttpUrlConnection
also has an internal pooling, but you have no tools to customize what or when to pool, no monitoring facilities to check the pool state.Keep in mind, that it also possible to use other backends (e.g. for non-blocking clients) with Jersey if you have an appropriate
com.sun.jersey.api.client.ClientHandler
implementation.