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 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 Slide

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

    • At Totango

    View Slide

  4. WHAT IS DROPWIZARD?
    • A collection of libraries

    • And some glue code

    • Goal:

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

    View 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 Slide

  6. DROPWIZARD IS
    OPINIONATED*
    • Jetty for HTTP

    • Jersey for REST (JAX-RS)

    • Jackson for JSON

    • Metrics for metrics

    • SLF4J, Logback for logging

    View 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 Slide

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

    • Joda Time

    View 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 Slide

  10. GETTING STARTED
    • Maven

    • Application class

    • Configuration class

    • Representation class (optional)

    • Resource class (optional)

    • Healthcheck

    View Slide

  11. MAVEN

    View Slide

  12. APPLICATION CLASS

    View Slide

  13. CONFIGURATION CLASS
    Reads from yml file

    View Slide

  14. CONFIGURATION FILE
    Example yml file

    View Slide

  15. REPRESENTATION CLASS

    View Slide

  16. RESOURCE CLASS

    View Slide

  17. REGISTER THE RESOURCE

    View Slide

  18. HEALTHCHECK

    View Slide

  19. HEALTHCHECK

    View Slide

  20. RUNNING

    View Slide

  21. RUNNING

    View Slide

  22. ADD COOL BANNERS

    View Slide

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

    • /ping

    • /healthcheck

    • /metrics

    • /threads

    View Slide

  24. EXTRA
    • Nice test support.

    • Validation

    • Servlets, Filters

    • Custom Representations

    • HTML Views

    View Slide

  25. EXTRA
    • Streaming output

    • Caching

    • Error Handling

    • SSL

    • Logging

    View Slide

  26. EXTRA
    • Metrics and Metrics Reporters

    • Commands (CLI)

    • Tasks (admin HTTP interface)

    • Managed Objects

    View Slide

  27. SUMMARY
    • Pros:

    • Easy, simple

    • Performant

    • ops friendly

    • Opinionated

    • No web container

    • Community!
    • Cons:

    • Opinionated

    • Eran will say more ;-)

    View Slide

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

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

    View Slide