Production Ready Web Services with Dropwizard

Preview:

DESCRIPTION

Portland Java User GroupMay 15, 2012

Citation preview

Production Ready Web Services with Dropwizard

Portland Java User GroupMay 15, 2012Sean Sullivan

• Gilt Groupe

• Dropwizard project

• Dropwizard at Gilt

Gilt Groupe

online retailer

May 2011

April 2012

What does Gilt sell?

Apparel

Kids toys and apparel

Home furnishings

Food

Local deals

Travel

Gilt technology

Portland NYC Dublin

Service oriented architecture

shopping cart service

checkout service

email service

payment service

product service

internal “service framework”

image credit: dealwithitportland.com

Dropwizard

• Jetty

• Jersey

• Jackson

• JDBI

• logback

• Yammer Metrics

• Google Guava

• Hibernate Validator

“Dropwizard consists mostly of glue code to automatically connect and configure these components”

Dropwizard modules

• dropwizard-core

• dropwizard-client

• dropwizard-db

• dropwizard-auth

• dropwizard-scala

• dropwizard-views

• dropwizard-testing

<dependencies> <dependency> <groupId>com.yammer.dropwizard</groupId> <artifactId>dropwizard-core</artifactId> <version>0.4.0</version> </dependency> <dependency> <groupId>com.yammer.dropwizard</groupId> <artifactId>dropwizard-scala</artifactId> <version>0.4.0</version> </dependency></dependencies>

Maven pom.xml

Java services extend com.yammer.dropwizard.Service

+

Scala services extend com.yammer.dropwizard.ScalaService

+

Service configuration

YAML + config class

import com.yammer.dropwizard.config.Configuration;

public class MyServiceConfiguration

extends Configuration {

// your config stuff

}

Other config

• com.yammer.dropwizard.config.HttpConfiguration

• com.yammer.dropwizard.config.LoggingConfiguration

• com.yammer.dropwizard.db.DatabaseConfiguration

Hello world

$ git clone git://github.com/sullis/dropwizard-helloworld.git

$ cd dropwizard-helloworld

$ mvn clean package

$ ./bin/dev.sh

Compile and run

Dropwizard at Gilt

gift certificate service

fraud service

Gift certificate demo

• Jackson ObjectMapper configuration

• Log4j appender config

• ZooKeeper registration

• MessagingManager class

dropwizard-gilt

https://groups.google.com/d/topic/dropwizard-user/sGEi3i8W1tY/discussion

Hibernate Validator + Scala case classes

SOA challenges

• deployment

• QA

• monitoring

• debugging

Questions?

THE END

Bonus slides

“Monitoring and QA are the same thing. You'd never think so until you try doing a big SOA. But when your service says "oh yes, I'm fine", it may well be the case that the only thing still functioning in the server is the little component that knows how to say "I'm fine, roger roger, over and out" in a cheery droid voice. In order to tell whether the service is actually responding, you have to make individual calls. The problem continues recursively until your monitoring is doing comprehensive semantics checking of your entire range of services and data, at which point it's indistinguishable from automated QA”

http://bit.ly/pityk6Steve Yegge, October 2011

http://bit.ly/pityk6Steve Yegge, October 2011

“If you have hundreds of services, and your code MUST communicate with other groups' code via these services, then you won't be able to find any of them without a service-discovery mechanism. And you can't have that without a service registration mechanism, which itself is another service. So Amazon has a universal service registry where you can find out reflectively (programmatically) about every service, what its APIs are, and also whether it is currently up, and where”