I have the following class that supposed to send messages to Oracle AQ defined application.yml.
@ApplicationScoped
public class BaseAQClient{
private static final Logger logger = LoggerFactory.getLogger(BaseAQClient.class);
@Outgoing("to-aq-pokemon")
public PublisherBuilder<String> publish(String msg) {
PublisherBuilder<String> result = ReactiveStreams.of(msg);
return result;
}
@Incoming("from-aq-pokemon")
public void consumeAq(String msg) {
logger.debug("Oracle AQ says: {}", msg);
}
}
When I want to send message I do something like that
BaseAQClient client = new BaseAQClient ();
CompletableFuture.supplyAsync(() -> client.publish(message))
.thenApply(result -> { logger.info("Message published successfully: {}", result);
return "Message published successfully: " + result;})
.exceptionally(e -> {logger.error("Error publishing message: {}", e.getMessage());
return "Error publishing message";});
It does not send messages at all and feels totally wrong to call the publishing method like this. But i can not find the correct way to do this. Also I do not need async option.
1