-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestTemplateConfig.java
More file actions
23 lines (20 loc) · 918 Bytes
/
Copy pathRestTemplateConfig.java
File metadata and controls
23 lines (20 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.crimeLink.analyzer.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
/**
* Configuration for RestTemplate bean used to communicate with ML microservices.
* Part of the hybrid monolith + microservices architecture.
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// Set timeout for ML service calls (30 seconds for heavy processing)
factory.setConnectTimeout(10000); // 10 seconds connection timeout
factory.setReadTimeout(30000); // 30 seconds read timeout (ML processing can be slow)
return new RestTemplate(factory);
}
}