topic
This commit is contained in:
32
src/main/java/fr/istic/date/topic/RecevoirDate.java
Normal file
32
src/main/java/fr/istic/date/topic/RecevoirDate.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package fr.istic.date.topic;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class RecevoirDate {
|
||||
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();
|
||||
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "topic");
|
||||
String queueName = channel.queueDeclare().getQueue();
|
||||
//la clé: locale
|
||||
channel.queueBind(queueName, EXCHANGE_NAME, "date.locale");
|
||||
|
||||
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
System.out.println(" [x] Received '" + message + "'");
|
||||
};
|
||||
channel.basicConsume(queueName, true, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/fr/istic/date/topic/RecevoirDateGMT.java
Normal file
32
src/main/java/fr/istic/date/topic/RecevoirDateGMT.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package fr.istic.date.topic;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class RecevoirDateGMT {
|
||||
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();
|
||||
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "topic");
|
||||
String queueName = channel.queueDeclare().getQueue();
|
||||
//la clé: GMT
|
||||
channel.queueBind(queueName, EXCHANGE_NAME, "date.gmt");
|
||||
|
||||
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
System.out.println(" [x] Received '" + message + "'");
|
||||
};
|
||||
channel.basicConsume(queueName, true, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user