Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(selector): Add getter to use listener externally #68

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> extends MQMessageListenerRetries {
public static final int SECONDS_TIMEOUT = 30;
Expand Down Expand Up @@ -51,6 +53,10 @@ public Mono<T> requestReply(MQMessageCreator messageCreator, Duration timeout) {
return sender.send(requestQueue, messageCreator).flatMap(id -> router.wait(id, timeout));
}

public Mono<T> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public Mono<Message> requestReply(MQMessageCreator messageCreator, Duration time
container.get(replyQueue)));
}

public Mono<Message> 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);
Expand Down