Вывод сообщения о том, что очередь не принимает сообщения

This commit is contained in:
2025-04-15 22:04:03 +03:00
parent def391aba9
commit 2089284c26

View File

@@ -20,12 +20,17 @@ public class Send {
try (Connection connection = factory.newConnection();
Channel channel = connection.createChannel()) {
channel.queueDeclarePassive(QUEUE_NAME);
channel.confirmSelect();
int count = 0;
while (true) {
String message = "Message from " + name + " #" + count++;
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
if (!channel.waitForConfirms()) {
System.out.println(" [!] Message was NOT confirmed!");
} else {
System.out.println(" [x] Sent '" + message + "'");
}
Thread.sleep(delay);
}
}