RED-9658: Remove old ocr service queues in migration #598

Merged
dominique.eiflaender1 merged 1 commits from RED-9658-queues into release/2.465.x 2024-07-16 10:38:07 +02:00

View File

@ -0,0 +1,37 @@
package com.iqser.red.service.persistence.management.v1.processor.migration;
import static com.iqser.red.service.persistence.management.v1.processor.configuration.MessagingConfiguration.OCR_STATUS_UPDATE_RESPONSE_DQL;
import static com.iqser.red.service.persistence.management.v1.processor.configuration.MessagingConfiguration.OCR_STATUS_UPDATE_RESPONSE_QUEUE;
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.beans.factory.InitializingBean;
import com.iqser.red.service.persistence.management.v1.processor.settings.FileManagementServiceSettings;
import lombok.RequiredArgsConstructor;
// This can not run with migration starter service, it needs to be an InitializingBean otherwise it would be executed after queue listeners are initialized
@RequiredArgsConstructor
public class OldQueueCleanup implements InitializingBean {
private final AmqpAdmin amqpAdmin;
private final FileManagementServiceSettings settings;
public static final String OCR_QUEUE = "ocrQueue";
public static final String OCR_DLQ = "ocrDLQ";
@Override
public void afterPropertiesSet() {
// This should only run in post upgrade hook
if (settings.isMigrateOnly()) {
amqpAdmin.deleteQueue(OCR_QUEUE);
amqpAdmin.deleteQueue(OCR_DLQ);
amqpAdmin.deleteQueue(OCR_STATUS_UPDATE_RESPONSE_QUEUE);
amqpAdmin.deleteQueue(OCR_STATUS_UPDATE_RESPONSE_DQL);
}
}
}