@@ -86,6 +86,8 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation("io.jsonwebtoken:jjwt:0.13.0")
|
||||
|
||||
//kafka
|
||||
implementation 'org.springframework.kafka:spring-kafka'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package ru.soune.nocopy.kafka;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MonitoringResultListener {
|
||||
|
||||
@KafkaListener(topics = "monitoring-results", groupId = "dashboard")
|
||||
public void handleCommand(String commandMessage) {
|
||||
log.info("Monitoring result: " + commandMessage);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -32,6 +33,8 @@ public class MonitoringScheduler {
|
||||
|
||||
private final NotificationService notificationService;
|
||||
|
||||
private final KafkaTemplate<String, FileMonitoringEntity> kafkaTemplate;
|
||||
|
||||
@Scheduled(cron = "0 1 2 * * *", zone = "Europe/Moscow")
|
||||
@Transactional
|
||||
public void processScheduledMonitoring() {
|
||||
|
||||
@@ -71,7 +71,8 @@ public class MonitoringSearchService {
|
||||
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
||||
|
||||
try {
|
||||
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens(), OperationType.MONITORING);
|
||||
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens(),
|
||||
OperationType.MONITORING);
|
||||
|
||||
boolean useYandex = searchProperties.getEngines().getOrDefault("yandex",
|
||||
new SearchProperties.EngineConfig()).isEnabled();
|
||||
|
||||
Reference in New Issue
Block a user