Removes deps on camel from activemq-web, code not needed for the
examples.
This commit is contained in:
Timothy Bish 2013-09-20 11:59:05 -04:00
parent efaa351db7
commit 062adbbe72
3 changed files with 8 additions and 59 deletions

View File

@ -32,7 +32,6 @@
<properties> <properties>
<activemq.osgi.import.pkg> <activemq.osgi.import.pkg>
org.apache.activemq*;resolution:=optional, org.apache.activemq*;resolution:=optional,
org.apache.camel*;resolution:=optional,
org.eclipse.jetty*;resolution:=optional, org.eclipse.jetty*;resolution:=optional,
org.springframework*;resolution:=optional, org.springframework*;resolution:=optional,
com.thoughtworks.xstream*;resolution:=optional, com.thoughtworks.xstream*;resolution:=optional,
@ -46,9 +45,10 @@
<dependencies> <dependencies>
<!-- activemq --> <!-- activemq -->
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>activemq-camel</artifactId> <artifactId>activemq-all</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>

View File

@ -129,28 +129,11 @@ public class MessageServlet extends MessageServletSupport {
boolean sync = isSync(request); boolean sync = isSync(request);
TextMessage message = client.getSession().createTextMessage(text); TextMessage message = client.getSession().createTextMessage(text);
if (sync) { appendParametersToMessage(request, message);
String point = "activemq:" boolean persistent = isSendPersistent(request);
+ ((ActiveMQDestination)destination).getPhysicalName().replace("//", "") int priority = getSendPriority(request);
+ "?requestTimeout=" + requestTimeout; long timeToLive = getSendTimeToLive(request);
try { client.send(destination, message, persistent, priority, timeToLive);
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);
}
// lets return a unique URI for reliable messaging // lets return a unique URI for reliable messaging
response.setHeader("messageID", message.getJMSMessageID()); response.setHeader("messageID", message.getJMSMessageID());

View File

@ -49,12 +49,6 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.MessageAvailableConsumer; import org.apache.activemq.MessageAvailableConsumer;
import org.apache.activemq.broker.BrokerRegistry; import org.apache.activemq.broker.BrokerRegistry;
import org.apache.activemq.broker.BrokerService; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -88,9 +82,6 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
private final Semaphore semaphore = new Semaphore(1); private final Semaphore semaphore = new Semaphore(1);
private CamelContext camelContext;
private ProducerTemplate producerTemplate;
private String username; private String username;
private String password; private String password;
@ -185,16 +176,12 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
if (connection != null) { if (connection != null) {
connection.close(); connection.close();
} }
if (producerTemplate != null) {
producerTemplate.stop();
}
} catch (Exception e) { } catch (Exception e) {
LOG.debug("caught exception closing consumer", e); LOG.debug("caught exception closing consumer", e);
} finally { } finally {
producer = null; producer = null;
session = null; session = null;
connection = null; connection = null;
producerTemplate = null;
if (consumers != null) { if (consumers != null) {
consumers.clear(); consumers.clear();
} }
@ -314,27 +301,6 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
servletContext.setAttribute(CONNECTION_FACTORY_ATTRIBUTE, factory); 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 { public synchronized MessageProducer getProducer() throws JMSException {
if (producer == null) { if (producer == null) {