1 package at.ac.tuwien.sbc.valesriegler.driver.jms;
3 import at.ac.tuwien.sbc.valesriegler.common.HasId;
4 import at.ac.tuwien.sbc.valesriegler.driver.jms.messageListeners.CookedDeliveryOrders;
5 import org.apache.activemq.ActiveMQConnectionFactory;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 import javax.jms.Connection;
10 import javax.jms.JMSException;
11 import javax.jms.MessageConsumer;
12 import javax.jms.Session;
15 * JMSDriver registers all the Listeners.
20 public class JMSDriver implements HasId {
21 private static final Logger log = LoggerFactory.getLogger(JMSDriver.class);
22 private final String CONNECTSTRING;
23 public String getCONNECTSTRING() {
29 public JMSDriver(String jmsURL, int id) {
30 CONNECTSTRING = jmsURL;
32 log.info("I AM A JMSDriver WITH ID {}", this.id);
35 // Connecting to the Broker and to the output queue
36 ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(CONNECTSTRING);
37 Connection connection = connectionFactory.createConnection();
40 Session sessCookedDeliveryOrders = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
41 MessageConsumer consCookedDeliveryOrders = sessCookedDeliveryOrders.createConsumer(sessCookedDeliveryOrders
42 .createQueue("CookedDeliveryOrders"));
43 consCookedDeliveryOrders.setMessageListener(new CookedDeliveryOrders(this));
44 } catch (JMSException e) {
45 log.error("EXCEPTION!", e);