Pull request #352: PortsFrom3.2.x
Merge in RED/redaction-service from portsFrom3.2.x to master * commit 'b13a695c64280a97ece198a18605c0f1b5cf753f': RED-3611: Added priority mode that only listens to priority queue RED-3620: Fixed remove from dictionary
This commit is contained in:
commit
c8cf0078eb
@ -0,0 +1,25 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.queue;
|
||||||
|
|
||||||
|
import static com.iqser.red.service.redaction.v1.server.queue.MessagingConfiguration.REDACTION_QUEUE;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MessageReceiver {
|
||||||
|
|
||||||
|
private final RedactionMessageReceiver redactionMessageReceiver;
|
||||||
|
|
||||||
|
@RabbitHandler
|
||||||
|
@RabbitListener(queues = REDACTION_QUEUE)
|
||||||
|
public void receiveAnalyzeRequest(String in) throws JsonProcessingException {
|
||||||
|
redactionMessageReceiver.receiveAnalyzeRequest(in, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,8 +1,10 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server.queue;
|
package com.iqser.red.service.redaction.v1.server.queue;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import org.springframework.amqp.core.Queue;
|
import org.springframework.amqp.core.Queue;
|
||||||
import org.springframework.amqp.core.QueueBuilder;
|
import org.springframework.amqp.core.QueueBuilder;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@ -10,11 +12,24 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MessagingConfiguration {
|
public class MessagingConfiguration {
|
||||||
|
|
||||||
|
|
||||||
public static final String REDACTION_QUEUE = "redactionQueue";
|
public static final String REDACTION_QUEUE = "redactionQueue";
|
||||||
|
|
||||||
public static final String REDACTION_DQL = "redactionDQL";
|
public static final String REDACTION_DQL = "redactionDQL";
|
||||||
|
|
||||||
|
public static final String REDACTION_PRIORITY_QUEUE = "redactionPriorityQueue";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "redaction-service", name = "priorityMode", havingValue = "false")
|
||||||
|
public MessageReceiver messageReceiver(RedactionMessageReceiver redactionMessageReceiver){
|
||||||
|
return new MessageReceiver(redactionMessageReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "redaction-service", name = "priorityMode", havingValue = "true")
|
||||||
|
public PriorityMessageReceiver priorityMessageReceiver(RedactionMessageReceiver redactionMessageReceiver){
|
||||||
|
return new PriorityMessageReceiver(redactionMessageReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Queue redactionQueue() {
|
public Queue redactionQueue() {
|
||||||
@ -27,9 +42,21 @@ public class MessagingConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue redactionPriorityQueue() {
|
||||||
|
|
||||||
|
return QueueBuilder.durable(REDACTION_PRIORITY_QUEUE)
|
||||||
|
.withArgument("x-dead-letter-exchange", "")
|
||||||
|
.withArgument("x-dead-letter-routing-key", REDACTION_DQL)
|
||||||
|
.maxPriority(2)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Queue redactionDeadLetterQueue() {
|
public Queue redactionDeadLetterQueue() {
|
||||||
|
|
||||||
return QueueBuilder.durable(REDACTION_DQL).build();
|
return QueueBuilder.durable(REDACTION_DQL).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.queue;
|
||||||
|
|
||||||
|
import static com.iqser.red.service.redaction.v1.server.queue.MessagingConfiguration.REDACTION_PRIORITY_QUEUE;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PriorityMessageReceiver {
|
||||||
|
|
||||||
|
private final RedactionMessageReceiver redactionMessageReceiver;
|
||||||
|
|
||||||
|
|
||||||
|
@RabbitHandler
|
||||||
|
@RabbitListener(queues = REDACTION_PRIORITY_QUEUE)
|
||||||
|
public void receiveAnalyzeRequest(String in) throws JsonProcessingException {
|
||||||
|
|
||||||
|
redactionMessageReceiver.receiveAnalyzeRequest(in, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -30,12 +30,10 @@ public class RedactionMessageReceiver {
|
|||||||
private final ManualRedactionSurroundingTextService manualRedactionSurroundingTextService;
|
private final ManualRedactionSurroundingTextService manualRedactionSurroundingTextService;
|
||||||
|
|
||||||
|
|
||||||
@RabbitHandler
|
public void receiveAnalyzeRequest(String in, boolean priority) throws JsonProcessingException {
|
||||||
@RabbitListener(queues = REDACTION_QUEUE)
|
|
||||||
public void receiveAnalyzeRequest(String in) throws JsonProcessingException {
|
|
||||||
|
|
||||||
var analyzeRequest = objectMapper.readValue(in, AnalyzeRequest.class);
|
var analyzeRequest = objectMapper.readValue(in, AnalyzeRequest.class);
|
||||||
log.info("Processing analyze request for file: {}", analyzeRequest.getFileId());
|
log.info("Processing priority: {} analyze request for file: {}", priority, analyzeRequest.getFileId());
|
||||||
AnalyzeResult result = null;
|
AnalyzeResult result = null;
|
||||||
|
|
||||||
switch (analyzeRequest.getMessageType()) {
|
switch (analyzeRequest.getMessageType()) {
|
||||||
|
|||||||
@ -99,8 +99,13 @@ public class DictionaryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<DictionaryEntry> entries = new HashSet<>();
|
Set<DictionaryEntry> entries = new HashSet<>();
|
||||||
|
var newEntries = convertEntries(t.getId(), currentVersion);
|
||||||
|
var newValues = newEntries.stream().map(v -> v.getValue()).collect(Collectors.toSet());
|
||||||
|
|
||||||
// add old entries from existing DictionaryModel
|
// add old entries from existing DictionaryModel
|
||||||
oldModel.ifPresent(dictionaryModel -> entries.addAll(dictionaryModel.getEntries()));
|
oldModel.ifPresent(dictionaryModel -> entries.addAll(dictionaryModel.getEntries().stream().filter(
|
||||||
|
f -> !newValues.contains(f.getValue())).collect(Collectors.toList())
|
||||||
|
));
|
||||||
// Add Increments
|
// Add Increments
|
||||||
entries.addAll(convertEntries(t.getId(), currentVersion));
|
entries.addAll(convertEntries(t.getId(), currentVersion));
|
||||||
|
|
||||||
|
|||||||
@ -20,4 +20,6 @@ public class RedactionServiceSettings {
|
|||||||
|
|
||||||
private boolean nerServiceEnabled = true;
|
private boolean nerServiceEnabled = true;
|
||||||
|
|
||||||
|
private boolean priorityMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user