spring-boot

Register Caffeine Cache in Spring Actuator (CacheManager)

一个人想着一个人 提交于 2021-02-18 19:00:07
问题 We're using Spring Boot 2 and Spring Actuator. When creating a cache like the following: @Bean public CaffeineCache someCache() { return new CaffeineCache("my-cache", Caffeine.newBuilder() .maximumSize(1000) .expireAfterWrite(10, TimeUnit.SECONDS) .build()); } it is registered into Spring Actuator and can be accessed and handle via endpoints: ❯ http GET localhost:8080/actuator/caches { "cacheManagers": { "cacheManager": { "caches": { "my-cache": { "target": "com.github.benmanes.caffeine.cache

Register Caffeine Cache in Spring Actuator (CacheManager)

一个人想着一个人 提交于 2021-02-18 18:59:54
问题 We're using Spring Boot 2 and Spring Actuator. When creating a cache like the following: @Bean public CaffeineCache someCache() { return new CaffeineCache("my-cache", Caffeine.newBuilder() .maximumSize(1000) .expireAfterWrite(10, TimeUnit.SECONDS) .build()); } it is registered into Spring Actuator and can be accessed and handle via endpoints: ❯ http GET localhost:8080/actuator/caches { "cacheManagers": { "cacheManager": { "caches": { "my-cache": { "target": "com.github.benmanes.caffeine.cache

Spring JPA QuerydslPredicate Snake Case

空扰寡人 提交于 2021-02-18 18:32:47
问题 I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE . So my json payload input and output is in snake case like below { "first_name": "First", "last_name": "Last" } I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below (http://localhost:8080/context/resource/?first_name=First) it is not parsed by Query DSL Predicate. However, If I provide the

Spring JPA QuerydslPredicate Snake Case

假装没事ソ 提交于 2021-02-18 18:31:32
问题 I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE . So my json payload input and output is in snake case like below { "first_name": "First", "last_name": "Last" } I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below (http://localhost:8080/context/resource/?first_name=First) it is not parsed by Query DSL Predicate. However, If I provide the

Spring JPA QuerydslPredicate Snake Case

孤街浪徒 提交于 2021-02-18 18:31:23
问题 I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE . So my json payload input and output is in snake case like below { "first_name": "First", "last_name": "Last" } I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below (http://localhost:8080/context/resource/?first_name=First) it is not parsed by Query DSL Predicate. However, If I provide the

How to increase the number of messages consumed by Spring Kafka Consumer in each batch?

…衆ロ難τιáo~ 提交于 2021-02-18 17:42:13
问题 I am building a Kafka Consumer application that consumes messages from a Kafka Topic and performs a database update task. The messages are produced in a large batch once every day - so the Topic has about 1 million messages loaded in 10 minutes. The Topic has 8 partitions. The Spring Kafka Consumer (annotated with @KafkaListener and using a ConcurrentKafkaListenerContainerFactory) is triggered in very short batches. The batch size is sometimes just 1 or 2 messages. It would help performance

Spring Boot Actuator - Multiple Health Endpoints

巧了我就是萌 提交于 2021-02-18 15:03:58
问题 Is there any way to support multiple health endpoints on a Spring Boot application? Here's why: The standard actuator health check is great, built in checks are great, customization options are great - for a single use case: reporting on general application health. But I'd like something I can call from an AWS Elastic Load Balancer / AutoScaling Group. By default, if an instance fails a health check, the ELB/ASG will terminate it and replace it with a fresh instance. The problem is some of

Spring Boot Actuator - Multiple Health Endpoints

ε祈祈猫儿з 提交于 2021-02-18 15:02:09
问题 Is there any way to support multiple health endpoints on a Spring Boot application? Here's why: The standard actuator health check is great, built in checks are great, customization options are great - for a single use case: reporting on general application health. But I'd like something I can call from an AWS Elastic Load Balancer / AutoScaling Group. By default, if an instance fails a health check, the ELB/ASG will terminate it and replace it with a fresh instance. The problem is some of

How can I get a custom Principal object with Spring using OAuth2?

我只是一个虾纸丫 提交于 2021-02-18 12:09:47
问题 I have a Spring Boot application utilizing spring-security-jwt and spring-security-oauth2. I've got a custom User object extending UserDetails and a Custom UserDetailsService returning this object from the loadUserByUsername method. But when I utilize the getPrincipal method of the Authentication object and try to Cast to my custom user object, it fails as the principal is returning a string vs my custom user object. My actual goal is to eliminate the trip to the persistence layer on every

RestTemplate set timeout per request

∥☆過路亽.° 提交于 2021-02-18 11:52:15
问题 I have a @Service with several methods, each method consumes a different web api. Each call should have a custom read timeout. Is it thread-safe to have one RestTemplate instance and change the timeout via the factory in each method like so ((HttpComponentsClientHttpRequestFactory)restTemplate.getRequestFactory()) .setReadTimeout(customMillis); My concern is that I'm changing the timeout on the factory and its not like a RequestConfig . Will this approach be thread-safe considering these