Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dropwizard

Ran Tavory
October 15, 2014

 Dropwizard

A gentle introduction to Dropwizard - a java microservices framework

Ran Tavory

October 15, 2014
Tweet

More Decks by Ran Tavory

Other Decks in Programming

Transcript

  1. A GENTLE INTRODUCTION TO

    DROPWIZARD
    Ran Tavory

    @rantav

    Gormim

    Totango

    View full-size slide

  2. ABOUT ME
    • Developer developer developer

    • Gormim

    • We help developers find awesome jobs.

    • You should register! www.gormim.com

    • Totango

    • Previously: outbrain, google, youtube, microsoft

    View full-size slide

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

    • At Totango

    View full-size slide

  4. WHAT IS DROPWIZARD?
    • A collection of libraries

    • And some glue code

    • Goal:

    • Make it easy to write (micro)services, in Java

    View full-size slide

  5. MICROSERVICES, YEAH
    • Goal: easy to create new services

    • Goal: simple to use

    • Goal: easy to deploy

    • Goal: easy to monitor, manage

    • devops friendly

    View full-size slide

  6. DROPWIZARD IS
    OPINIONATED*
    • Jetty for HTTP

    • Jersey for REST (JAX-RS)

    • Jackson for JSON

    • Metrics for metrics

    • SLF4J, Logback for logging

    View full-size slide

  7. … 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

    View full-size slide

  8. … IS OPINIONATED*
    • Freemarker and Mustach for templating

    • Joda Time

    View full-size slide

  9. *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

    View full-size slide

  10. GETTING STARTED
    • Maven

    • Application class

    • Configuration class

    • Representation class (optional)

    • Resource class (optional)

    • Healthcheck

    View full-size slide

  11. APPLICATION CLASS

    View full-size slide

  12. CONFIGURATION CLASS
    Reads from yml file

    View full-size slide

  13. CONFIGURATION FILE
    Example yml file

    View full-size slide

  14. REPRESENTATION CLASS

    View full-size slide

  15. RESOURCE CLASS

    View full-size slide

  16. REGISTER THE RESOURCE

    View full-size slide

  17. ADD COOL BANNERS

    View full-size slide

  18. OPS FRIENDLY
    • Now you can access the following URLs:

    • /ping

    • /healthcheck

    • /metrics

    • /threads

    View full-size slide

  19. EXTRA
    • Nice test support.

    • Validation

    • Servlets, Filters

    • Custom Representations

    • HTML Views

    View full-size slide

  20. EXTRA
    • Streaming output

    • Caching

    • Error Handling

    • SSL

    • Logging

    View full-size slide

  21. EXTRA
    • Metrics and Metrics Reporters

    • Commands (CLI)

    • Tasks (admin HTTP interface)

    • Managed Objects

    View full-size slide

  22. SUMMARY
    • Pros:

    • Easy, simple

    • Performant

    • ops friendly

    • Opinionated

    • No web container

    • Community!
    • Cons:

    • Opinionated

    • Eran will say more ;-)

    View full-size slide

  23. REFS
    • https://dropwizard.github.io/dropwizard/

    • http://martinfowler.com/articles/microservices.html

    View full-size slide