From 2089284c26b0b49a1b513921df0b91dbc28d8af5 Mon Sep 17 00:00:00 2001 From: Arity-T Date: Tue, 15 Apr 2025 22:04:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20=D1=82?= =?UTF-8?q?=D0=BE=D0=BC,=20=D1=87=D1=82=D0=BE=20=D0=BE=D1=87=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D1=8C=20=D0=BD=D0=B5=20=D0=BF=D1=80=D0=B8=D0=BD?= =?UTF-8?q?=D0=B8=D0=BC=D0=B0=D0=B5=D1=82=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/java/dev/tishenko/producer/Send.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lab3/producer/app/src/main/java/dev/tishenko/producer/Send.java b/lab3/producer/app/src/main/java/dev/tishenko/producer/Send.java index a321444..edb2ef6 100644 --- a/lab3/producer/app/src/main/java/dev/tishenko/producer/Send.java +++ b/lab3/producer/app/src/main/java/dev/tishenko/producer/Send.java @@ -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()); - System.out.println(" [x] Sent '" + message + "'"); + if (!channel.waitForConfirms()) { + System.out.println(" [!] Message was NOT confirmed!"); + } else { + System.out.println(" [x] Sent '" + message + "'"); + } Thread.sleep(delay); } }