Articles


Introduction

While developing applications using Spring batch, especially in a micro-service project, we sometimes face one or most of the following cases:

  • The necessity of getting the security context inside the batch items to call methods that require authorizations inside the same micro-service or perform remote processing by calling other micro-services using Feign Client (HTTP) or  Spring Cloud Stream (broker like Kafka, RabbitMq …)
  • Propagating Sleuth trace Id and span Id in order to enhance logs traceability inside all the application components including other micro-services so the trace will not be lost if we use Job.
  • Getting the connected user Locale (i18n) in order to generate internationalized output otherwise, all the Job outputs will be generated in the default server language.
  • Retrieving objects stored inside Mapped Diagnostic Context  (MDC) for tracing purposes.

The following schema illustrates remote calls that can be performed in a micro-service-based application and the context information that String Batch items can propagate.

Source de l’article sur DZONE

Today I am going to provide you an example of a small microservices based application, where I am going to implement a Eureka discovery server to register all the microservices application in it, so that each of these services can be accessible from all the microservices applications registered with Discovery Server. 

For this example, we are going to create total four microservices applications/services. 

Source de l’article sur DZONE

@FeignClient(name = "service-provider")
public interface EchoService { @RequestMapping(value = "/echo/{str}", method = RequestMethod.GET) String echo(@PathVariable("str") String str);
}

What Is Sentinel

Sentinel is an open source circuit breaker. It can be part of Spring Cloud Alibaba or as an individual package.

What Is Feign

Feign is a Java to HTTP client binder. It’s aiming to simplify the REST API process.

Source de l’article sur DZONE