| 23295 |
ashik.ali |
1 |
package com.spice.profitmandi.price;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
|
|
4 |
|
|
|
5 |
import org.slf4j.Logger;
|
|
|
6 |
import org.slf4j.LoggerFactory;
|
|
|
7 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
8 |
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
9 |
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
10 |
import org.springframework.stereotype.Component;
|
|
|
11 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
12 |
|
|
|
13 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
|
|
14 |
import com.spice.profitmandi.web.config.AppConfig;
|
|
|
15 |
|
|
|
16 |
@Transactional
|
|
|
17 |
@Component
|
|
|
18 |
public class PriceDropScheduler {//implements Runnable{
|
|
|
19 |
|
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(PriceDropScheduler.class);
|
|
|
21 |
|
|
|
22 |
@Autowired
|
|
|
23 |
private PriceDropService priceDropService;
|
|
|
24 |
|
|
|
25 |
@Scheduled(fixedDelay = 3000)
|
|
|
26 |
public void checkAndAddPriceDropAmountToWallet() {
|
|
|
27 |
priceDropService.addPriceDropAmountToWallet();
|
|
|
28 |
LOGGER.info("Check and add price drop Amount to wallet at {}", LocalDateTime.now());
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public static void main(String[] args) {
|
|
|
32 |
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
|
|
|
33 |
String scheduledAnnotationProcessor = "org.springframework.context.annotation.internalScheduledAnnotationProcessor";
|
|
|
34 |
System.out.println("Contains " + scheduledAnnotationProcessor + ": "+ context.containsBean(scheduledAnnotationProcessor));
|
|
|
35 |
try {
|
|
|
36 |
Thread.sleep(8000);
|
|
|
37 |
} catch (InterruptedException e) {
|
|
|
38 |
e.printStackTrace();
|
|
|
39 |
} finally {
|
|
|
40 |
//context.close();
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
}
|