read me en cours
This commit is contained in:
36
src/main/java/fr/istic/chat/chat.java
Normal file
36
src/main/java/fr/istic/chat/chat.java
Normal 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 -> {
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user