0

We are evaluating Light 4j and considering using it for a project instead of Spring Boot. We have some questions before we begin.

Like the general business handlers, guess a custom handler can be defined as part of a chain. a) are the handlers executed in order in which those are defined ? b) what if a handler does not wish to forward the request to next handler in chain and return a response to client ?

are these handler chains similar to servlet filters ?

Sourajit Basak
  • 693
  • 5
  • 15

1 Answers1

1

The light-4j supports multiple chains in an application per endpoint so that you can define the different combinations of middleware handlers and business handlers. Yes. The handlers in a chain will be executed in a defined sequence. Here is one of the examples with two chains

https://github.com/networknt/light-config-test/blob/master/light-router/test-portal/config/handler.yml

There are two types of handlers:

middleware handlers are plugins in the middle of the chain and pass the control to the next handler if it is executed successfully. However, if there are errors, it still returns the error the client to break the chain.

business handlers are endpoint handler that is executed to perform the business logic.

There are two types of middleware handlers:

Technical middleware handlers are provided by light-4j and they address the common gateway cross-cutting concerns at the technical level.

Business middleware handlers are running within the business context to address cross-cutting concerns like fine-grained authorization, business auditing, etc. Most of our big users are developing their in-house business middleware handlers to extend the platform.

Yes. The light-4j middleware handlers are similar to Servlet Filters but they are more efficient. With servlet, the request and response are immutable and very hard to manipulate. Also, the servlet stack adds too much overhead with minimum multi-thread support. Light-4j is working on the core HTTP level without any extra overhead.

In this article, we simply replace the servlet filter with light-4j middleware handlers and the performance difference is significant.

https://doc.networknt.com/benchmark/spring-boot/

Steve Hu
  • 358
  • 2
  • 10