I was recently tasked at my company to move one of our services that's not deployed to prod yet from dropwizard 0.7.1 to dropwizard 0.8.0-rc1. It's a fairly basic service that takes a POST request and logs it to a file for logging and analytic purposes.
I just wanted to briefly share what my pain points were with the migration for others to be aware about. In general, the migration was straight-forward on the dropwizard side, but, in migrating our dropwizard boilerplate libraries that had a lot of jersey specific functionality, I found myself having to change just about everything we do. A lot of these changes are covered here
https://jersey.java.net/documentation/latest/migration.html. Here's the list of things I found having to change:
1.) Client filters: It seemed that there was no longer a 'ClientFilter' class and ended up having to replace it with ClientRequestFilter. The filter no longer seems to act as a passthrough where the handle() method returns a transformed/filtered request object, but I guess you're supposed to now change the request in place?
2.) In our boilerplate library, we also have a module for boilerplate client functionality. I had to change all references of com.sun.jersey.Client to use javax.ws.rs.client.Client, which was pretty straight forward.
3.) In changing to Java's Client, some of the resource endpoints changed. The resource() method now returns WebTarget rather than WebResource, and there is no longer an asyncResource() method because WebTarget allows you to invoke it asynchronously. This allowed me to remove a lot of our 'async' boilerplate methods.
4.) In some instances, I had to use readEntity() instead of getEntity()
5.) HttpRequestContext seemed to no longer be available, so I found a suitable replacement using ContainerRequest
6.) In one of the unit tests for a filter, I was using the dropwizard resource test rule. The filter itself depended on the injection of HttpServletRequest, which seemed to no longer be injected by default, so, I had to write my own HK2 injection binder to inject a mocked version of this value.
7.) The way basic authentication is done has changed. On the service side, we would have to register a provider called BasicAuthProvider<>, and now instead, we register a BasicAuthFactory<> which is wrapped with AuthFactory.binder(). On the client side, to embed credentials, before we would register a HTTPBasicAuthFilter, and now we register an instance returned by HttpAuthenticationFeature.basic().
8.) In our boilerplate client code, I was receiving an exception when trying to call put() on Client with a null entity. This was due to http validation, which can be turned off by adding the property ClientProperties.SUPPRESS_HTTP_CLIENT_VALIDATION to the client with a value of true.
I did like the fact that now I could easily inject our resources using HK2's AbstractBinder, something I've been wanting to do with Guice reliably for some time. Beyond all these changes I made, I also did some basic load testing to verify that there were no significant performance penalties in switching, since this is a high-throughput service. I tested performance using siege running on my laptop, sending requests to an instance of the service running on a remote box. I ran 625 concurrent requests, each with a 0-1 sec. delay and here are the results I got:
BEFORE (Dropwizard 0.7.1)
RUN 1
Transactions: 59299 hits
Availability: 100.00 %
Elapsed time: 59.68 secs
Data transferred: 16.57 MB
Response time: 0.12 secs
Transaction rate: 993.62 trans/sec
Throughput: 0.28 MB/sec
Concurrency: 118.86
Successful transactions: 0
Failed transactions: 0
Longest transaction: 1.48
Shortest transaction: 0.00
RUN 2
Transactions: 60339 hits
Availability: 100.00 %
Elapsed time: 59.14 secs
Data transferred: 16.86 MB
Response time: 0.10 secs
Transaction rate: 1020.27 trans/sec
Throughput: 0.29 MB/sec
Concurrency: 105.45
Successful transactions: 0
Failed transactions: 0
Longest transaction: 1.41
Shortest transaction: 0.00
AFTER (Dropwizard 0.8.0-rc1)
RUN 1
Transactions: 61320 hits
Availability: 100.00 %
Elapsed time: 59.79 secs
Data transferred: 17.13 MB
Response time: 0.10 secs
Transaction rate: 1025.59 trans/sec
Throughput: 0.29 MB/sec
Concurrency: 106.55
Successful transactions: 0
Failed transactions: 0
Longest transaction: 1.42
Shortest transaction: 0.00
RUN 2
Transactions: 60320 hits
Availability: 100.00 %
Elapsed time: 59.52 secs
Data transferred: 16.86 MB
Response time: 0.10 secs
Transaction rate: 1013.44 trans/sec
Throughput: 0.28 MB/sec
Concurrency: 106.30
Successful transactions: 0
Failed transactions: 0
Longest transaction: 1.61
Shortest transaction: 0.00
As the results show, switching over had no impact on overall performance. So, in general, I didn't run into too many problems on the dropwizard side, albeit this service is fairly basic and doesn't use a lot of extended dropwizard functionality. The bulk of the changes were really in the jersey filters and injections providers we use.