You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to understand how can I detect that my broker is down when I'm trying to send a message without blocking? I was using this code as it's described from the documentation:
public void sendAsMessageWithAck(double d) {
emitterForPrices.send(Message.of(d, () -> {
// Called when the message is acknowledged.
return CompletableFuture.completedFuture(null);
},
reason -> {
// Called when the message is acknowledged negatively.
return CompletableFuture.completedFuture(null);
}));
I was expecting that the message would be Nacked (as per a default timeout) and I could then take some action. I know that I can achieve this the following way as described below, but this would be blocking.
public void sendAndAwaitAcknowledgement(double d) {
CompletionStage<Void> acked = emitterForPrices.send(d);
// sending a payload returns a CompletionStage completed
// when the message is acknowledged
acked.toCompletableFuture().orTimeout(1000,TimeUnit.MILLISECONDS).join();
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all!
I'm trying to understand how can I detect that my broker is down when I'm trying to send a message without blocking? I was using this code as it's described from the documentation:
I was expecting that the message would be Nacked (as per a default timeout) and I could then take some action. I know that I can achieve this the following way as described below, but this would be blocking.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions