From 062adbbe7278f63d3b4102e063e3bfea213754df Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 20 Sep 2013 11:59:05 -0400 Subject: [PATCH] fix for: https://issues.apache.org/jira/browse/AMQ-4059 Removes deps on camel from activemq-web, code not needed for the examples. --- activemq-web/pom.xml | 6 ++-- .../apache/activemq/web/MessageServlet.java | 27 +++------------ .../org/apache/activemq/web/WebClient.java | 34 ------------------- 3 files changed, 8 insertions(+), 59 deletions(-) diff --git a/activemq-web/pom.xml b/activemq-web/pom.xml index bf7f6109ee..58510cdcdc 100755 --- a/activemq-web/pom.xml +++ b/activemq-web/pom.xml @@ -32,7 +32,6 @@ org.apache.activemq*;resolution:=optional, - org.apache.camel*;resolution:=optional, org.eclipse.jetty*;resolution:=optional, org.springframework*;resolution:=optional, com.thoughtworks.xstream*;resolution:=optional, @@ -46,9 +45,10 @@ + - ${project.groupId} - activemq-camel + ${project.groupId} + activemq-all ${project.groupId} diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java index 06948f9dd3..f099aeb464 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java @@ -129,28 +129,11 @@ public class MessageServlet extends MessageServletSupport { boolean sync = isSync(request); TextMessage message = client.getSession().createTextMessage(text); - if (sync) { - String point = "activemq:" - + ((ActiveMQDestination)destination).getPhysicalName().replace("//", "") - + "?requestTimeout=" + requestTimeout; - try { - String body = (String)client.getProducerTemplate().requestBody(point, text); - ActiveMQTextMessage answer = new ActiveMQTextMessage(); - answer.setText(body); - - writeMessageResponse(response.getWriter(), answer); - } catch (Exception e) { - IOException ex = new IOException(); - ex.initCause(e); - throw ex; - } - } else { - appendParametersToMessage(request, message); - boolean persistent = isSendPersistent(request); - int priority = getSendPriority(request); - long timeToLive = getSendTimeToLive(request); - client.send(destination, message, persistent, priority, timeToLive); - } + appendParametersToMessage(request, message); + boolean persistent = isSendPersistent(request); + int priority = getSendPriority(request); + long timeToLive = getSendTimeToLive(request); + client.send(destination, message, persistent, priority, timeToLive); // lets return a unique URI for reliable messaging response.setHeader("messageID", message.getJMSMessageID()); diff --git a/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java b/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java index 4b25ca3b12..66ca782f24 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java @@ -49,12 +49,6 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.MessageAvailableConsumer; import org.apache.activemq.broker.BrokerRegistry; import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.camel.component.ActiveMQComponent; -import org.apache.activemq.camel.component.ActiveMQConfiguration; -import org.apache.activemq.pool.PooledConnectionFactory; -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.impl.DefaultCamelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,9 +82,6 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind private final Semaphore semaphore = new Semaphore(1); - private CamelContext camelContext; - private ProducerTemplate producerTemplate; - private String username; private String password; @@ -185,16 +176,12 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind if (connection != null) { connection.close(); } - if (producerTemplate != null) { - producerTemplate.stop(); - } } catch (Exception e) { LOG.debug("caught exception closing consumer", e); } finally { producer = null; session = null; connection = null; - producerTemplate = null; if (consumers != null) { consumers.clear(); } @@ -314,27 +301,6 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind servletContext.setAttribute(CONNECTION_FACTORY_ATTRIBUTE, factory); } } - - public synchronized CamelContext getCamelContext() { - if (camelContext == null) { - LOG.debug("Creating camel context"); - camelContext = new DefaultCamelContext(); - ActiveMQConfiguration conf = new ActiveMQConfiguration(); - conf.setConnectionFactory(new PooledConnectionFactory((ActiveMQConnectionFactory)factory)); - ActiveMQComponent component = new ActiveMQComponent(conf); - camelContext.addComponent("activemq", component); - } - return camelContext; - } - - public synchronized ProducerTemplate getProducerTemplate() throws Exception { - if (producerTemplate == null) { - LOG.debug("Creating producer template"); - producerTemplate = getCamelContext().createProducerTemplate(); - producerTemplate.start(); - } - return producerTemplate; - } public synchronized MessageProducer getProducer() throws JMSException { if (producer == null) {