Lagom Circuit Breaker: What, Why and How?

Knoldus

When our service depends on a third party service’s end point for response, it is possible that due to various reasons, that may vary from bad connection to an internal server error from the third party, our own service fails. A circuit breaker is employed to prevent cascading failures in our services if such scenarios were to occur. And if you are here, you are probably looking forward to customise the circuit breaker within your own service. So, shall we?

First of, when working with lagom in java, the circuit breaker functionality is on even if you don’t do anything about it. But it is always better to customise things to suit our own needs, right? So let’s first get the concept of circuit breaker clear in our head. A circuit breaker can have one of the following three states at an instant:

  1. Closed,
  2. Open, and
  3. Half-Open

Also, there are…

View original post 1,021 more words

Routing DSL in Akka HTTP

Knoldus

Hi Guys,

In this blog we’ll be discussing about the Routing DSl provided by Akka HTTP High level Server SideAPI.

Akka HTTP provides a very flexible “Routing DSL” for elegantly defining RESTful web services. It picks up where the low-level API leaves off and offers much of the higher level functionality of typical web servers or frameworks, like deconstruction of URIs, content negotiation or static content serving.

-> Why do we need Routing DSL ?

The Akka HTTP Low-Level Server-Side API provides a Flow- or Function-level interface that allows an application to respond to incoming HTTP requests by simply mapping requests to responses:

case HttpRequest(GET, Uri.Path("/ping"), _, _, _) => HttpResponse(entity = "PONG!")

case HttpRequest(GET, Uri.Path("/pong"), _, _, _) => HttpResponse(entity = "PING!")

In the above case when the requested URI is “ping” case one follows and when URI is “pong” case…

View original post 459 more words

Play 2.3.x PDF : Basic example for generating PDF documents dynamically from Play Application with the help of play2-pdf module

Knoldus

alt tag

In this blog I have created a basic example for generating PDF documents dynamically from Play Application with the help of play2-pdf module

Play 2.3.x PDF module: This module helps generating PDF documents dynamically from your Play! web application. It simply renders your HTML- and CSS-based templates to PDF. It is based on the Flying Saucer library, which in turn uses iText for PDF generation.

Usage

You can use a standard Play! Scala template like this one:

@(message: String)

@main("Play!ng PDF") {
    Image: <imgsrc="/public/images/favicon.png"/><br/>
    Hello world! <br/>
    @message <br/>
}

Check the below template list for more complex template design:

  1. Letter PDF
  2. News Letter PDF

Then this template, after having imported it.innove.PdfGenerator, can simply be rendered as:

defletter:Action[AnyContent] =Action { implicit request =>Ok(PdfGenerator.toBytes(views.html.letter("

View original post 281 more words

Blog at WordPress.com.

Up ↑