Slide 1

Slide 1 text

A GENTLE INTRODUCTION TO DROPWIZARD Ran Tavory @rantav Gormim Totango

Slide 2

Slide 2 text

ABOUT ME • Developer developer developer • Gormim • We help developers find awesome jobs. • You should register! www.gormim.com • Totango • Previously: outbrain, google, youtube, microsoft

Slide 3

Slide 3 text

MY EXPERIENCE WITH DROPWIZARD • So far implemented 3 microsevices with DW • At Totango

Slide 4

Slide 4 text

WHAT IS DROPWIZARD? • A collection of libraries • And some glue code • Goal: • Make it easy to write (micro)services, in Java

Slide 5

Slide 5 text

MICROSERVICES, YEAH • Goal: easy to create new services • Goal: simple to use • Goal: easy to deploy • Goal: easy to monitor, manage • devops friendly

Slide 6

Slide 6 text

DROPWIZARD IS OPINIONATED* • Jetty for HTTP • Jersey for REST (JAX-RS) • Jackson for JSON • Metrics for metrics • SLF4J, Logback for logging

Slide 7

Slide 7 text

… IS OPINIONATED* • Guava b/c it’s useful • Hibernate Validator (JSR-303) for data validation • Apache HTTP Client for low level HTTP • Jersey HTTP client for high level HTTP • jDBI for relational databases • Liquibase for DB schema maintenance

Slide 8

Slide 8 text

… IS OPINIONATED* • Freemarker and Mustach for templating • Joda Time

Slide 9

Slide 9 text

*SOME MODULARITY IN PLACE • Maven artifacts: • dropwizard-core! • dropwizard-client (http client) • dropwizard-jdbi! • dropwizard-migrations (liquibase) • dropwizard-hibernate! • dropwizard-auth (HTTP basic and oauth2) • dropwizard-views- mustache and dropwizard-views- freemarker! • dropwizard-scala! • dropwizard-testing

Slide 10

Slide 10 text

GETTING STARTED • Maven • Application class • Configuration class • Representation class (optional) • Resource class (optional) • Healthcheck

Slide 11

Slide 11 text

MAVEN

Slide 12

Slide 12 text

APPLICATION CLASS

Slide 13

Slide 13 text

CONFIGURATION CLASS Reads from yml file

Slide 14

Slide 14 text

CONFIGURATION FILE Example yml file

Slide 15

Slide 15 text

REPRESENTATION CLASS

Slide 16

Slide 16 text

RESOURCE CLASS

Slide 17

Slide 17 text

REGISTER THE RESOURCE

Slide 18

Slide 18 text

HEALTHCHECK

Slide 19

Slide 19 text

HEALTHCHECK

Slide 20

Slide 20 text

RUNNING

Slide 21

Slide 21 text

RUNNING

Slide 22

Slide 22 text

ADD COOL BANNERS

Slide 23

Slide 23 text

OPS FRIENDLY • Now you can access the following URLs: • /ping • /healthcheck • /metrics • /threads

Slide 24

Slide 24 text

EXTRA • Nice test support. • Validation • Servlets, Filters • Custom Representations • HTML Views

Slide 25

Slide 25 text

EXTRA • Streaming output • Caching • Error Handling • SSL • Logging

Slide 26

Slide 26 text

EXTRA • Metrics and Metrics Reporters • Commands (CLI) • Tasks (admin HTTP interface) • Managed Objects

Slide 27

Slide 27 text

SUMMARY • Pros: • Easy, simple • Performant • ops friendly • Opinionated • No web container • Community! • Cons: • Opinionated • Eran will say more ;-)

Slide 28

Slide 28 text

REFS • https://dropwizard.github.io/dropwizard/ • http://martinfowler.com/articles/microservices.html