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

Dropwizard

2cdc5c3059c40c76d5ca7bec8d149f9e?s=47 Ran Tavory
October 15, 2014

 Dropwizard

A gentle introduction to Dropwizard - a java microservices framework

2cdc5c3059c40c76d5ca7bec8d149f9e?s=128

Ran Tavory

October 15, 2014
Tweet

Transcript

  1. A GENTLE INTRODUCTION TO DROPWIZARD Ran Tavory @rantav Gormim Totango

  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
  3. MY EXPERIENCE WITH DROPWIZARD • So far implemented 3 microsevices

    with DW • At Totango
  4. WHAT IS DROPWIZARD? • A collection of libraries • And

    some glue code • Goal: • Make it easy to write (micro)services, in Java
  5. MICROSERVICES, YEAH • Goal: easy to create new services •

    Goal: simple to use • Goal: easy to deploy • Goal: easy to monitor, manage • devops friendly
  6. DROPWIZARD IS OPINIONATED* • Jetty for HTTP • Jersey for

    REST (JAX-RS) • Jackson for JSON • Metrics for metrics • SLF4J, Logback for logging
  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
  8. … IS OPINIONATED* • Freemarker and Mustach for templating •

    Joda Time
  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
  10. GETTING STARTED • Maven • Application class • Configuration class

    • Representation class (optional) • Resource class (optional) • Healthcheck
  11. MAVEN

  12. APPLICATION CLASS

  13. CONFIGURATION CLASS Reads from yml file

  14. CONFIGURATION FILE Example yml file

  15. REPRESENTATION CLASS

  16. RESOURCE CLASS

  17. REGISTER THE RESOURCE

  18. HEALTHCHECK

  19. HEALTHCHECK

  20. RUNNING

  21. RUNNING

  22. ADD COOL BANNERS

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

    • /ping • /healthcheck • /metrics • /threads
  24. EXTRA • Nice test support. • Validation • Servlets, Filters

    • Custom Representations • HTML Views
  25. EXTRA • Streaming output • Caching • Error Handling •

    SSL • Logging
  26. EXTRA • Metrics and Metrics Reporters • Commands (CLI) •

    Tasks (admin HTTP interface) • Managed Objects
  27. SUMMARY • Pros: • Easy, simple • Performant • ops

    friendly • Opinionated • No web container • Community! • Cons: • Opinionated • Eran will say more ;-)
  28. REFS • https://dropwizard.github.io/dropwizard/ • http://martinfowler.com/articles/microservices.html