From b6100fe146f5e5adaff9fe06f2e85563a51bdfd6 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Tue, 14 May 2013 13:29:02 +0200 Subject: [PATCH] hanged connectstring to be one global var. --- src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java | 2 ++ .../java/at/ac/tuwien/sbc/valesriegler/cook/jms/JMSCook.java | 3 ++- .../valesriegler/cook/jms/messageListeners/OrdersToCook.java | 3 ++- .../tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java | 3 ++- .../sbc/valesriegler/pizzeria/jms/JMSPizzeriaConnector.java | 3 ++- .../at/ac/tuwien/sbc/valesriegler/waiter/jms/JMSWaiter.java | 3 ++- .../valesriegler/waiter/jms/messageListeners/CookedOrders.java | 3 ++- .../valesriegler/waiter/jms/messageListeners/WantToOrder.java | 3 ++- .../valesriegler/waiter/jms/messageListeners/WantToPay.java | 3 ++- .../waiter/jms/messageListeners/WantToSitAtTable.java | 3 ++- 10 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java index de46881..65ce4aa 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java @@ -42,6 +42,8 @@ public abstract class Util { public static final String SERVER_ADDR = "xvsm://localhost:9876"; + public static final String JMS_CONNECTSTRING = "tcp://localhost:61616?jms.prefetchPolicy.all=1"; + public static ContainerReference getOrCreateNamedContainer(final String spaceUri, final String containerName, final Capi capi, final List coordinators) throws MzsCoreException { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/JMSCook.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/JMSCook.java index 32aa897..103bd0f 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/JMSCook.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/JMSCook.java @@ -10,6 +10,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.ac.tuwien.sbc.valesriegler.common.HasId; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.cook.jms.messageListeners.OrdersToCook; /** @@ -29,7 +30,7 @@ public class JMSCook implements HasId { try { // Connecting to the Broker and to the output queue - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/messageListeners/OrdersToCook.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/messageListeners/OrdersToCook.java index 042cef0..b9a2dd3 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/messageListeners/OrdersToCook.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/cook/jms/messageListeners/OrdersToCook.java @@ -13,6 +13,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.cook.actions.OrderInfo; import at.ac.tuwien.sbc.valesriegler.cook.jms.JMSCook; import at.ac.tuwien.sbc.valesriegler.group.actions.OrderRequest; @@ -51,7 +52,7 @@ public class OrdersToCook implements MessageListener { pizzaorder.setStatus(PizzaOrderStatus.IN_PREPARATION); } - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java index 2e1c7b7..831eeb5 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java @@ -15,6 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.ac.tuwien.sbc.valesriegler.common.AbstractAction; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.group.AbstractGroupConnector; import at.ac.tuwien.sbc.valesriegler.group.Group; import at.ac.tuwien.sbc.valesriegler.group.GroupAgent; @@ -41,7 +42,7 @@ public class JMSGroupConnector extends AbstractGroupConnector implements Message @Override public void init() { try { - connection = new ActiveMQConnectionFactory("tcp://localhost:61616").createConnection(); + connection = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING).createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(session.createQueue("GroupConnector")); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/jms/JMSPizzeriaConnector.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/jms/JMSPizzeriaConnector.java index e90a7da..8b71caf 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/jms/JMSPizzeriaConnector.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/jms/JMSPizzeriaConnector.java @@ -17,6 +17,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.ac.tuwien.sbc.valesriegler.common.AbstractAction; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.cook.actions.OrderInfo; import at.ac.tuwien.sbc.valesriegler.group.actions.OrderResponse; import at.ac.tuwien.sbc.valesriegler.group.actions.PayResponse; @@ -44,7 +45,7 @@ public class JMSPizzeriaConnector extends AbstractPizzeriaConnector implements M @Override public void init() { try { - connection = new ActiveMQConnectionFactory("tcp://localhost:61616").createConnection(); + connection = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING).createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(session.createQueue("PizzeriaConnector")); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/JMSWaiter.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/JMSWaiter.java index 39b4479..d483127 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/JMSWaiter.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/JMSWaiter.java @@ -10,6 +10,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.waiter.jms.messageListeners.CookedOrders; import at.ac.tuwien.sbc.valesriegler.waiter.jms.messageListeners.WantToOrder; import at.ac.tuwien.sbc.valesriegler.waiter.jms.messageListeners.WantToPay; @@ -32,7 +33,7 @@ public class JMSWaiter implements Serializable { try { // Connecting to the Broker and to the output queue - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/CookedOrders.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/CookedOrders.java index 4ad83e7..443962e 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/CookedOrders.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/CookedOrders.java @@ -13,6 +13,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.cook.actions.OrderInfo; import at.ac.tuwien.sbc.valesriegler.types.OrderStatus; import at.ac.tuwien.sbc.valesriegler.waiter.actions.DeliverOrder; @@ -48,7 +49,7 @@ public class CookedOrders implements MessageListener { // generate random delay Thread.sleep((long) (Math.random() * 10000)); - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToOrder.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToOrder.java index 396cbd1..916a610 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToOrder.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToOrder.java @@ -13,6 +13,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.group.actions.OrderRequest; import at.ac.tuwien.sbc.valesriegler.group.actions.OrderResponse; import at.ac.tuwien.sbc.valesriegler.waiter.jms.JMSWaiter; @@ -47,7 +48,7 @@ public class WantToOrder implements MessageListener { // generate random delay Thread.sleep((long) (Math.random() * 10000)); - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToPay.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToPay.java index 6a8e858..3952be7 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToPay.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToPay.java @@ -13,6 +13,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.group.actions.PayRequest; import at.ac.tuwien.sbc.valesriegler.group.actions.PayResponse; import at.ac.tuwien.sbc.valesriegler.waiter.jms.JMSWaiter; @@ -47,7 +48,7 @@ public class WantToPay implements MessageListener { // generate random delay Thread.sleep((long) (Math.random() * 10000)); - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToSitAtTable.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToSitAtTable.java index 2caed2f..6dce8d8 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToSitAtTable.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/jms/messageListeners/WantToSitAtTable.java @@ -14,6 +14,7 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.group.actions.TableRequest; import at.ac.tuwien.sbc.valesriegler.group.actions.TableResponse; import at.ac.tuwien.sbc.valesriegler.types.Table; @@ -49,7 +50,7 @@ public class WantToSitAtTable implements MessageListener { // generate random delay Thread.sleep((long) (Math.random() * 10000)); - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(Util.JMS_CONNECTSTRING); Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); -- 2.43.0