From 040ca795086b108428afdd8eca8905afce6d1d42 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Tue, 5 Jun 2018 03:14:03 +0200 Subject: [PATCH] [3.1] refactored queues - removed manual bindings. --- .../java/dst/ass3/messaging/impl/QueueManager.java | 5 ----- .../java/dst/ass3/messaging/impl/RequestGateway.java | 10 +++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ass3-messaging/src/main/java/dst/ass3/messaging/impl/QueueManager.java b/ass3-messaging/src/main/java/dst/ass3/messaging/impl/QueueManager.java index 4c34145..4713ce8 100644 --- a/ass3-messaging/src/main/java/dst/ass3/messaging/impl/QueueManager.java +++ b/ass3-messaging/src/main/java/dst/ass3/messaging/impl/QueueManager.java @@ -27,11 +27,6 @@ public class QueueManager implements IQueueManager { channel.queueDeclare(qname, true, false, false, null); } - //some manual work needed: routing keys not loopable :( - channel.queueBind(Constants.QUEUE_DOCUMENT, Constants.TOPIC_EXCHANGE, Constants.ROUTING_KEY_DOCUMENT); - channel.queueBind(Constants.QUEUE_QUIZ, Constants.TOPIC_EXCHANGE, Constants.ROUTING_KEY_QUIZ); - channel.queueBind(Constants.QUEUE_VIDEO, Constants.TOPIC_EXCHANGE, Constants.ROUTING_KEY_VIDEO); - channel.close(); conn.close(); } catch (IOException | TimeoutException e) { diff --git a/ass3-messaging/src/main/java/dst/ass3/messaging/impl/RequestGateway.java b/ass3-messaging/src/main/java/dst/ass3/messaging/impl/RequestGateway.java index 13b435b..13bb9b6 100644 --- a/ass3-messaging/src/main/java/dst/ass3/messaging/impl/RequestGateway.java +++ b/ass3-messaging/src/main/java/dst/ass3/messaging/impl/RequestGateway.java @@ -36,21 +36,21 @@ public class RequestGateway implements IRequestGateway { String routingKey = null; switch (request.getType()) { case DOCUMENT: - routingKey = Constants.ROUTING_KEY_DOCUMENT; + routingKey = Constants.QUEUE_DOCUMENT; break; case QUIZ: - routingKey = Constants.ROUTING_KEY_QUIZ; + routingKey = Constants.QUEUE_QUIZ; break; case VIDEO: - routingKey = Constants.ROUTING_KEY_VIDEO; + routingKey = Constants.QUEUE_VIDEO; break; } ObjectMapper mapper = new ObjectMapper(); try { - channel.basicPublish(Constants.TOPIC_EXCHANGE, routingKey, false, false, MessageProperties.BASIC, mapper.writeValueAsBytes(request)); + channel.basicPublish("", routingKey, false, false, MessageProperties.BASIC, mapper.writeValueAsBytes(request)); } catch (IOException e) { - e.printStackTrace(); // TODO: may not be irrecoverable! + e.printStackTrace(); // TODO: may be recoverable? } } -- 2.43.0