Переполнение есть
This commit is contained in:
@@ -8,14 +8,29 @@ public class Send {
|
||||
private static final String QUEUE_NAME = "hello";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String delayEnv = System.getenv("PRODUCER_DELAY_MS");
|
||||
int delay = delayEnv != null ? Integer.parseInt(delayEnv) : 1000;
|
||||
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("rabbitmq");
|
||||
|
||||
try (Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel()) {
|
||||
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
||||
String message = "Hello World!";
|
||||
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
|
||||
System.out.println(" [x] Sent '" + message + "'");
|
||||
|
||||
boolean durable = false;
|
||||
boolean exclusive = false;
|
||||
boolean autoDelete = false;
|
||||
|
||||
// channel.queueDeclare(QUEUE_NAME, durable, exclusive, autoDelete, null);
|
||||
channel.queueDeclarePassive(QUEUE_NAME);
|
||||
|
||||
int count = 0;
|
||||
while (true) {
|
||||
String message = "Message #" + count++;
|
||||
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
|
||||
System.out.println(" [x] Sent '" + message + "'");
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user