Skip to content

Commit

Permalink
fix(scheduler): Save single scheduler on selector instantiation (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
juancgalvis authored Jul 4, 2024
1 parent cac3699 commit cb06892
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message> getMessage(String correlationId) {
Expand Down Expand Up @@ -49,6 +53,6 @@ public Mono<Message> getMessageBySelector(String selector, long timeout, Destina

private Mono<Message> doAsync(Supplier<Message> supplier) {
return Mono.fromSupplier(supplier)
.subscribeOn(Schedulers.fromExecutor(executorService));
.subscribeOn(scheduler);
}
}

0 comments on commit cb06892

Please sign in to comment.