Fading Coder

One Final Commit for the Last Sprint

Connecting Multiple RabbitMQ Brokers in Spring Boot

Spring Boot’s AMQP auto-configuration is great for a single RabbitMQ broker, but many systems need to talk to more than one. To support multiple brokers, define separate ConnectionFactory, RabbitTemplate, RabbitAdmin, and listener container factory beans for each broker and mark one as primary. Conf...

Spring Boot MyBatis with Two MySQL DataSources Using Druid

Required dependencies application.properties: define two data sources and poooling Java configuration for both data sources MyBatis mappers for each data source Controller endpoints to verify both connecsions Sample project layout and test URLs Dependencies <!-- MySQL JDBC driver --> <depe...

Spring Boot and RabbitMQ: JSON Serialization for Producers and Listeners

RabbitMQ transports raw bytes. Too exchange domain objects as JSON, you can serialize manually or configure Spring AMQP to handle JSON automatically for both producers and consumers. Manual JSON serialization with ObjectMapper You can convert a POJO to JSON yourself and publish the resulting bytes....

Fix LocalDateTime deserialization errors when converting JSON to objects in Spring Boot

Symptom When a request body contains date-time strings such as "2020-05-04 00:00" and the target fields are of type java.time.LocalDateTime, Spring Boot (via Jackson) fails to deserialize: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserial...

Implementing Login Enforcement in Spring Boot 2.x with a Custom Annotation and HandlerInterceptor

Most endpoints in many applications require authentication. In Spring Boot 2.x, a common pattern is to decorate controllers or handler methods with a custom annotation and enforce that contract via a HandlerInterceptor. This guide shows how to: Declare a marker annotation to indicate that an endpoin...

Building Service Registration and Discovery with Spring Boot and Spring Cloud Eureka

Overview Eureka, created by Netflix, is a registry for service discovery in microservice architectures. Each provider registers itself with Eureka, while consumers query Eureka to locate instances. Although Netflix has ended active maintenance of Eureka 2.x, the Eureka 1.x implementation in Spring C...

Distributed Locking with Redis in Spring Boot using Spring Integration

How to integrate Redis with Spring Boot to build a lightweight distributed locking mechanism using Spring Integration’s RedisLockRegistry. It also touches on the internal design so you can tune behavior and avoid common pitfalls. Why Redis-based distributed locks When multiple application instances...