// Path: src/main/java/com/dogeops/cantilever/truss/client/ning/HTTPAsyncLogMessageListener.java
// public class HTTPAsyncLogMessageListener implements MessageListener {
// 	private static final Logger logger = Logger.getLogger(HTTPAsyncLogMessageListener.class
// 			.getName());
// 	
// 	private Builder builder;
// 	private AsyncHttpClient client;
// 
//     public HTTPAsyncLogMessageListener() {
// 		builder = new AsyncHttpClientConfig.Builder();
// 		builder.setCompressionEnabled(true)
// 			.setMaximumConnectionsPerHost(100)
// 		    .setRequestTimeoutInMs(15000)
// 		    .build();
// 		
// 		client = new AsyncHttpClient(builder.build());
//     }
// 	
// 	public enum AcceptableMethods {
// 		GET, POST, NAN;
// 		public static AcceptableMethods getValue(String str) {
// 			try {
// 				return valueOf(str);
// 			} catch (Exception e) {
// 				logger.error(e.getMessage());
// 				return NAN;
// 			}
// 		}
// 	}
// 	
// 	public void onMessage(Message message) {
// 		 if (message instanceof TextMessage) {
//              TextMessage textMessage = (TextMessage) message;
//              String text;
// 			try {
// 				text = textMessage.getText();
// 				Gson gson = new Gson();
// 				HTTPLogObject http_log = gson.fromJson(text, HTTPLogObject.class);
// 				
// 				switch (AcceptableMethods.getValue(http_log.getMethod()))
// 				{
// 				    case GET:
// 				    	new HTTPAsyncGet(client, http_log);
// 				    	break;
// 				    case POST:
// 				    	new HTTPAsyncPost(client, http_log);
// 				    	break;
// 				    default:
// 				    	logger.error("Unsupport HTTP Method: " + http_log.getMethod());
// 				}
// 				
// 				logger.trace("Received: " + text);
// 			} catch (JMSException e) {
// 				logger.error(e.getMessage());
// 			}
//          } else {
// 			logger.error("Received an erroneous message: " + message);
// 		}
// 
// 	}
// 
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/Util.java
// public class Util {
// 	public static void cease(Logger logger, String message) {
// 		logger.error(message);
// 		System.exit(1);
// 	}
// }


import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.log4j.Logger;
import com.dogeops.cantilever.truss.client.ning.HTTPAsyncLogMessageListener;
import com.dogeops.cantilever.utils.Util;
package com.dogeops.cantilever.messagequeue;




public class ActiveMQ implements MessageQueueInterface {
	private static final Logger logger = Logger.getLogger(ActiveMQ.class
			.getName());

	public ActiveMQConnectionFactory connectionFactory;
	public Connection connection;
	public Session session;
	public Destination destination;
	public MessageProducer producer;

	public void connect(String hostname, String queue_name) {
		try {
			logger.debug("Connecting to ActiveMQ Broker: " + hostname + " - Queue: " + queue_name);
			connectionFactory = new ActiveMQConnectionFactory(hostname);
			connection = connectionFactory.createConnection();
			connection.start();
			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
			destination = session.createQueue(queue_name);
		} catch (JMSException e) {
			Util.cease(logger, e.getMessage());
		}
	}

	public void disconnect() {
		try {
			// We need to get some more details in this log message...
			logger.debug("Disconnecting from ActiveMQ Broker");
			connection.close();
		} catch (JMSException e) {
// Path: src/main/java/com/dogeops/cantilever/truss/client/ning/HTTPAsyncLogMessageListener.java
// public class HTTPAsyncLogMessageListener implements MessageListener {
// 	private static final Logger logger = Logger.getLogger(HTTPAsyncLogMessageListener.class
// 			.getName());
// 	
// 	private Builder builder;
// 	private AsyncHttpClient client;
// 
//     public HTTPAsyncLogMessageListener() {
// 		builder = new AsyncHttpClientConfig.Builder();
// 		builder.setCompressionEnabled(true)
// 			.setMaximumConnectionsPerHost(100)
// 		    .setRequestTimeoutInMs(15000)
// 		    .build();
// 		
// 		client = new AsyncHttpClient(builder.build());
//     }
// 	
// 	public enum AcceptableMethods {
// 		GET, POST, NAN;
// 		public static AcceptableMethods getValue(String str) {
// 			try {
// 				return valueOf(str);
// 			} catch (Exception e) {
// 				logger.error(e.getMessage());
// 				return NAN;
// 			}
// 		}
// 	}
// 	
// 	public void onMessage(Message message) {
// 		 if (message instanceof TextMessage) {
//              TextMessage textMessage = (TextMessage) message;
//              String text;
// 			try {
// 				text = textMessage.getText();
// 				Gson gson = new Gson();
// 				HTTPLogObject http_log = gson.fromJson(text, HTTPLogObject.class);
// 				
// 				switch (AcceptableMethods.getValue(http_log.getMethod()))
// 				{
// 				    case GET:
// 				    	new HTTPAsyncGet(client, http_log);
// 				    	break;
// 				    case POST:
// 				    	new HTTPAsyncPost(client, http_log);
// 				    	break;
// 				    default:
// 				    	logger.error("Unsupport HTTP Method: " + http_log.getMethod());
// 				}
// 				
// 				logger.trace("Received: " + text);
// 			} catch (JMSException e) {
// 				logger.error(e.getMessage());
// 			}
//          } else {
// 			logger.error("Received an erroneous message: " + message);
// 		}
// 
// 	}
// 
// }
// 
// Path: src/main/java/com/dogeops/cantilever/utils/Util.java
// public class Util {
// 	public static void cease(Logger logger, String message) {
// 		logger.error(message);
// 		System.exit(1);
// 	}
// }


// Path: src/main/java/com/dogeops/cantilever/messagequeue/ActiveMQ.java
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.log4j.Logger;
import com.dogeops.cantilever.truss.client.ning.HTTPAsyncLogMessageListener;
import com.dogeops.cantilever.utils.Util;

package com.dogeops.cantilever.messagequeue;




public class ActiveMQ implements MessageQueueInterface {
	private static final Logger logger = Logger.getLogger(ActiveMQ.class
			.getName());

	public ActiveMQConnectionFactory connectionFactory;
	public Connection connection;
	public Session session;
	public Destination destination;
	public MessageProducer producer;

	public void connect(String hostname, String queue_name) {
		try {
			logger.debug("Connecting to ActiveMQ Broker: " + hostname + " - Queue: " + queue_name);
			connectionFactory = new ActiveMQConnectionFactory(hostname);
			connection = connectionFactory.createConnection();
			connection.start();
			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
			destination = session.createQueue(queue_name);
		} catch (JMSException e) {
			Util.cease(logger, e.getMessage());
		}
	}

	public void disconnect() {
		try {
			// We need to get some more details in this log message...
			logger.debug("Disconnecting from ActiveMQ Broker");
			connection.close();
		} catch (JMSException e) {
			Util.cease(logger, e.getMessage());