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