| 35547 |
amit |
1 |
package com.spice.profitmandi.dao.config;
|
|
|
2 |
|
|
|
3 |
import org.springframework.context.annotation.Bean;
|
|
|
4 |
import org.springframework.context.annotation.Configuration;
|
|
|
5 |
import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
6 |
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
7 |
|
|
|
8 |
import java.util.concurrent.Executor;
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* Configuration for async processing of Solr updates.
|
|
|
12 |
* Enables non-blocking Solr updates when TagListing changes.
|
|
|
13 |
*/
|
|
|
14 |
@Configuration
|
|
|
15 |
@EnableAsync
|
|
|
16 |
public class AsyncConfig {
|
|
|
17 |
|
|
|
18 |
@Bean(name = "solrUpdateExecutor")
|
|
|
19 |
public Executor solrUpdateExecutor() {
|
|
|
20 |
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
21 |
executor.setCorePoolSize(2);
|
|
|
22 |
executor.setMaxPoolSize(5);
|
|
|
23 |
executor.setQueueCapacity(100);
|
|
|
24 |
executor.setThreadNamePrefix("solr-update-");
|
|
|
25 |
executor.initialize();
|
|
|
26 |
return executor;
|
|
|
27 |
}
|
| 35956 |
amit |
28 |
|
|
|
29 |
@Bean(name = "mailOutboxExecutor")
|
|
|
30 |
public Executor mailOutboxExecutor() {
|
|
|
31 |
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
32 |
executor.setCorePoolSize(2);
|
|
|
33 |
executor.setMaxPoolSize(5);
|
|
|
34 |
executor.setQueueCapacity(200);
|
|
|
35 |
executor.setThreadNamePrefix("mail-outbox-");
|
|
|
36 |
executor.initialize();
|
|
|
37 |
return executor;
|
|
|
38 |
}
|
| 36999 |
amit |
39 |
|
| 37651 |
vikas |
40 |
/**
|
|
|
41 |
* Fetches LMS call recordings from the telephony provider into our object store. Single-threaded
|
|
|
42 |
* on purpose: these are multi-MB downloads and the point is to drain them steadily in the
|
|
|
43 |
* background, not to saturate the link the moment a busy hour ends.
|
|
|
44 |
*/
|
|
|
45 |
@Bean(name = "recordingArchiveExecutor")
|
|
|
46 |
public Executor recordingArchiveExecutor() {
|
|
|
47 |
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
48 |
executor.setCorePoolSize(1);
|
|
|
49 |
executor.setMaxPoolSize(2);
|
|
|
50 |
executor.setQueueCapacity(500);
|
|
|
51 |
executor.setThreadNamePrefix("recording-archive-");
|
|
|
52 |
executor.initialize();
|
|
|
53 |
return executor;
|
|
|
54 |
}
|
|
|
55 |
|
| 36999 |
amit |
56 |
@Bean(name = "priceHikeExecutor")
|
|
|
57 |
public Executor priceHikeExecutor() {
|
|
|
58 |
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
59 |
executor.setCorePoolSize(1);
|
|
|
60 |
executor.setMaxPoolSize(3);
|
|
|
61 |
executor.setQueueCapacity(100);
|
|
|
62 |
executor.setThreadNamePrefix("price-hike-");
|
|
|
63 |
executor.initialize();
|
|
|
64 |
return executor;
|
|
|
65 |
}
|
| 35547 |
amit |
66 |
}
|