Skip to content
Snippets Groups Projects
Commit 0165bc4f authored by Alexis Durgnat's avatar Alexis Durgnat :milky_way:
Browse files

sendBytes, recvBytes done

parent 52885f73
No related branches found
No related tags found
1 merge request!21*poof* final version
......@@ -3,6 +3,7 @@ package ch.hepia.mq;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Delivery;
public class MessageQueue{
private final String exchange;
......@@ -16,7 +17,18 @@ public class MessageQueue{
this.queueConnector.setPassword(password);
}
public void sendBytes(byte[] bytes){
public void sendBytes(byte[] bytes) throws Exception {
try (Connection connection = this.queueConnector.newConnection(); Channel channel = connection.createChannel()) {
channel.basicPublish(this.exchange, "", null, bytes);
// System.out.println(" [x] Sent '" + bytes + "'");
channel.close();
connection.close();
}
}
public byte[] recvBytes(Delivery delivery) throws Exception {
byte[] data = delivery.getBody();
return data;
}
public void close(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment