diff --git a/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/AbstractMQRequestReplyListener.java b/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/AbstractMQRequestReplyListener.java index 8355b50..8ae6ed8 100644 --- a/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/AbstractMQRequestReplyListener.java +++ b/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/AbstractMQRequestReplyListener.java @@ -7,11 +7,13 @@ import jakarta.jms.Destination; import jakarta.jms.Message; import jakarta.jms.Queue; +import lombok.Getter; import lombok.extern.log4j.Log4j2; import reactor.core.publisher.Mono; import java.time.Duration; +@Getter @Log4j2 public abstract class AbstractMQRequestReplyListener extends MQMessageListenerRetries { public static final int SECONDS_TIMEOUT = 30; @@ -51,6 +53,10 @@ public Mono requestReply(MQMessageCreator messageCreator, Duration timeout) { return sender.send(requestQueue, messageCreator).flatMap(id -> router.wait(id, timeout)); } + public Mono requestReply(String message, Destination request, Duration timeout) { + return sender.send(request, defaultCreator(message)).flatMap(id -> router.wait(id, timeout)); + } + private MQMessageCreator defaultCreator(String message) { return ctx -> { Message jmsMessage = ctx.createTextMessage(message); diff --git a/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/MQRequestReplySelector.java b/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/MQRequestReplySelector.java index d54f624..8be02bb 100644 --- a/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/MQRequestReplySelector.java +++ b/commons-jms-mq/src/main/java/co/com/bancolombia/commons/jms/mq/listeners/MQRequestReplySelector.java @@ -63,6 +63,11 @@ public Mono requestReply(MQMessageCreator messageCreator, Duration time container.get(replyQueue))); } + public Mono requestReply(String message, Destination request, Destination reply, Duration timeout) { + return sender.send(request, defaultCreator(message)) + .flatMap(id -> listener.getMessageBySelector(selector.buildSelector(id), timeout.toMillis(), reply)); + } + private MQMessageCreator defaultCreator(String message) { return ctx -> { Message jmsMessage = ctx.createTextMessage(message);