diff --git a/commons-jms-utils/src/main/java/co/com/bancolombia/commons/jms/internal/listener/selector/MQMultiContextMessageSelectorListener.java b/commons-jms-utils/src/main/java/co/com/bancolombia/commons/jms/internal/listener/selector/MQMultiContextMessageSelectorListener.java index b95b5ed..c82bc69 100644 --- a/commons-jms-utils/src/main/java/co/com/bancolombia/commons/jms/internal/listener/selector/MQMultiContextMessageSelectorListener.java +++ b/commons-jms-utils/src/main/java/co/com/bancolombia/commons/jms/internal/listener/selector/MQMultiContextMessageSelectorListener.java @@ -4,18 +4,22 @@ import co.com.bancolombia.commons.jms.api.MQMessageSelectorListenerSync; import jakarta.jms.Destination; import jakarta.jms.Message; -import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Schedulers; import java.util.function.Supplier; @Log4j2 -@AllArgsConstructor public class MQMultiContextMessageSelectorListener implements MQMessageSelectorListener { private final MQMessageSelectorListenerSync listenerSync; // MQMultiContextMessageSelectorListenerSync - private final MQExecutorService executorService; + private final Scheduler scheduler; + + public MQMultiContextMessageSelectorListener(MQMessageSelectorListenerSync listenerSync, MQExecutorService executorService) { + this.listenerSync = listenerSync; + this.scheduler = Schedulers.fromExecutor(executorService); + } @Override public Mono getMessage(String correlationId) { @@ -49,6 +53,6 @@ public Mono getMessageBySelector(String selector, long timeout, Destina private Mono doAsync(Supplier supplier) { return Mono.fromSupplier(supplier) - .subscribeOn(Schedulers.fromExecutor(executorService)); + .subscribeOn(scheduler); } }