read me en cours

This commit is contained in:
trochas
2025-04-22 16:30:56 +02:00
parent 7829971974
commit 29cc56d238
3 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package fr.istic.chat;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.DeliverCallback;
public class chat {
private static final String EXCHANGE_NAME = "topic_log";
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setUri("amqps://cyvthtfj:O8LmaXkX5mVB0oFZN9TobaK8rX9wEhol@whale.rmq.cloudamqp.com/cyvthtfj");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
String message = "";
if(false){
channel.basicPublish(EXCHANGE_NAME, argv[0], null, message.getBytes("UTF-8"));
}
String queueName = channel.queueDeclare().getQueue();
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
String message2 = new String(delivery.getBody(), "UTF-8");
System.out.println(" [x] Received '" + message2 + "'");
};
channel.basicConsume(queueName, true, deliverCallback, consumerTag -> {
});
}
}