spring-boot

Spring boot Webservice / Microservices and scheduling

耗尽温柔 提交于 2021-02-11 15:11:41
问题 I am having a spring boot application which exposes REST APIs and also am planning to add a spring boot scheduled task. The purpose of task is to pick up some pending 'reservations' from data store which is momgodb and process it. Now the question is when multiple instances of service running, there is high probability all the nodes will pick up same 'reservation records'. I was looking at mongodb lock for this and was checking updateAndModidy / transactions (in 4.x) of mongodb. Also

How to remove X-B3 prefix form Sleuth logs

微笑、不失礼 提交于 2021-02-11 15:06:07
问题 I want to remove X-Span-Export":"true","X-B3-SpanId":"40bcdc1c4fcdb9c0","X-B3-TraceId":"40bcdc1c4fcdb9c0"} form my log . I have added below configuration to application.yml but no help. Application.yml spring: application: name: app-name profiles: dev sleuth: sampler: probability : 1.0 log: slf4j: whitelisted-mdc-keys: principal baggage-keys: principal JSON Log {"@timestamp":"2020-12-02T13:58:35.343+03:00","@version":"1","message":"Request {}helloChasis from chasis-ms","logger_name":"az.iba

Spring Data/JPA: How do I save an item with multiple child collections?

半城伤御伤魂 提交于 2021-02-11 15:04:36
问题 I am struggling with understanding how to use Spring Data/JPA to interact with a database. I'm using the simple H2 database currently for testing purposes. I have a main item, Task , that in addition to fields, also has two collections of "child" data: TaskNote and StateChangeHistory . In my task service class, I have a @PostConstruct method to set up some dummy data and save it to the database so that I can retrieve and display it later. It appears that the Task is being saved, but none of

Jbpm7 spring boot business application: No active transaction after arjuna transation timeout

混江龙づ霸主 提交于 2021-02-11 15:04:22
问题 I'm encountering the same problem described here: https://issues.redhat.com/plugins/servlet/mobile#issue/RHBPMS-4621. I use Jbpm 7.41 business application with oracle database. Under high load, transaction timeouts are detected and arjuna marks them for rollback. Then, the Jbpm executor thread reuses the same transaction and throws a repetitive message "No active transaction...". Does someone know how to fix this problem? I think that the same fix done for JtaTransactionManager in RHBPMS-4621

RestTemplate convertor stopped working by adding interceptor

六眼飞鱼酱① 提交于 2021-02-11 15:01:34
问题 I have a spring boot 2 application, in which I have to log every request and response made by using Rest Template. For instance, if I have to call another service, this needs to get logged in my db. For this, I made the following changes in the Rest Template Config @Configuration @Getter public class RestTemplateConfig { @Bean public RestTemplate restTemplate() { RestTemplate template = new RestTemplate(); List<ClientHttpRequestInterceptor> interceptors = template.getInterceptors(); if

How to load only profile specific property file and ignore default application.properties?

可紊 提交于 2021-02-11 15:00:55
问题 I have a normal spring boot application, and two property files in resources folder: application.properties com.example.prop1=value1 com.example.enableMock=true application-dev.properties com.example.prop1=value11 I have some logic based on whether com.example.enableMock is present or missing. Problem is spring loads both files even if spring.profiles.active=dev and the application is getting the com.example.enableMock property. How do I just load profile specific property file? 回答1: By

Spring alternative to JAXRSClientFactory

我怕爱的太早我们不能终老 提交于 2021-02-11 14:58:31
问题 I have an interface with javax-ws-rs annotations for endpoints, and I am creating JAXRSClientFactory from cxf. Interface looks like this @Path("/ws") public interface TheWebServiceResource { @Path( "/" ) @Produces( { MediaType.APPLICATION_JSON } ) @GET Response handshake() ; } Then I create the resource TheWebServiceResource myResource = JAXRSClientFactory.create(url, cls, providers, features, conf); Now I know I could change the annotations to spring ones - @RequestMapping above the

Having configuration files outside jar file in Spring Boot

跟風遠走 提交于 2021-02-11 14:52:22
问题 I have a Spring boot camel application whose directory structure is like this I want to convert this project into a jar file. But I want 3 files outside my jar so that I don't need to redeploy my application again and again when the configuration is changed. those 3 files are application.properties CamelContext.xml sql.properties I have the flexibility to hardcode the path of the file location. Can anyone help me out how do I achieve this? 回答1: Since I have resolved the issue I will post the

Spring Batch : One Reader, composite processor (two classes with different entities) and two kafkaItemWriter

不打扰是莪最后的温柔 提交于 2021-02-11 14:51:38
问题 ItemReader is reading data from DB2 and gave java object ClaimDto . Now the ClaimProcessor takes in the object of ClaimDto and return CompositeClaimRecord object which comprises of claimRecord1 and claimRecord2 which to be sent to two different Kafka topics. How to write claimRecord1 and claimRecord2 to topic1 and topic2 respectively. 回答1: Just write a custom ItemWriter that does exactly that. public class YourItemWriter implements ItemWriter<CompositeClaimRecord>` { private final ItemWriter

Spring Batch : One Reader, composite processor (two classes with different entities) and two kafkaItemWriter

笑着哭i 提交于 2021-02-11 14:51:05
问题 ItemReader is reading data from DB2 and gave java object ClaimDto . Now the ClaimProcessor takes in the object of ClaimDto and return CompositeClaimRecord object which comprises of claimRecord1 and claimRecord2 which to be sent to two different Kafka topics. How to write claimRecord1 and claimRecord2 to topic1 and topic2 respectively. 回答1: Just write a custom ItemWriter that does exactly that. public class YourItemWriter implements ItemWriter<CompositeClaimRecord>` { private final ItemWriter