git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1183143 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-10-13 22:28:47 +00:00
parent 4acd13243a
commit 88f60580e3
3 changed files with 151 additions and 95 deletions

View File

@ -16,6 +16,8 @@
*/ */
package org.apache.activemq.camel.component; package org.apache.activemq.camel.component;
import java.util.concurrent.TimeUnit;
import org.apache.camel.CamelContext; import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder; import org.apache.camel.builder.RouteBuilder;
@ -67,6 +69,36 @@ public class ActiveMQRouteTest extends CamelTestSupport {
return camelContext; return camelContext;
} }
@Test
public void testInvalidDestinationOptionOnConsumer() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(0);
assertMockEndpointsSatisfied(1, TimeUnit.SECONDS);
try {
new RouteBuilder() {
public void configure() throws Exception {
from("activemq:queue:foo?destination.consumer.exclusive=true&destination.consumer.unknown=foo")
.to("mock:result");
}
};
} catch (Exception e) {
fail("Should not have accepted bad destination options.");
}
}
@Test
public void testInvalidDestinationOptionOnProducer() throws Exception {
try {
new RouteBuilder() {
public void configure() throws Exception {
from("activemq:queue:foo")
.to("activemq:queue:bar?destination.producer.exclusive=true");
}
};
} catch (Exception e) {
fail("Should not have accepted bad destination options.");
}
}
protected RouteBuilder createRouteBuilder() throws Exception { protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() { return new RouteBuilder() {
public void configure() throws Exception { public void configure() throws Exception {

View File

@ -225,6 +225,15 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
if (dest.getOptions() != null) { if (dest.getOptions() != null) {
Map<String, String> options = new HashMap<String, String>(dest.getOptions()); Map<String, String> options = new HashMap<String, String>(dest.getOptions());
IntrospectionSupport.setProperties(this.info, options, "consumer."); IntrospectionSupport.setProperties(this.info, options, "consumer.");
if (options.size() > 0) {
String msg = "There are " + options.size()
+ " consumer options that couldn't be set on the consumer."
+ " Check the options are spelled correctly."
+ " Unknown parameters=[" + options + "]."
+ " This consumer cannot be started.";
LOG.warn(msg);
throw new ConfigurationException(msg);
}
} }
this.info.setDestination(dest); this.info.setDestination(dest);

View File

@ -33,6 +33,8 @@ import org.apache.activemq.management.StatsCapable;
import org.apache.activemq.management.StatsImpl; import org.apache.activemq.management.StatsImpl;
import org.apache.activemq.usage.MemoryUsage; import org.apache.activemq.usage.MemoryUsage;
import org.apache.activemq.util.IntrospectionSupport; import org.apache.activemq.util.IntrospectionSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* A client uses a <CODE>MessageProducer</CODE> object to send messages to a * A client uses a <CODE>MessageProducer</CODE> object to send messages to a
@ -68,6 +70,8 @@ import org.apache.activemq.util.IntrospectionSupport;
*/ */
public class ActiveMQMessageProducer extends ActiveMQMessageProducerSupport implements StatsCapable, Disposable { public class ActiveMQMessageProducer extends ActiveMQMessageProducerSupport implements StatsCapable, Disposable {
private static final Logger LOG = LoggerFactory.getLogger(ActiveMQMessageProducer.class);
protected ProducerInfo info; protected ProducerInfo info;
protected boolean closed; protected boolean closed;
@ -81,10 +85,21 @@ public class ActiveMQMessageProducer extends ActiveMQMessageProducerSupport impl
super(session); super(session);
this.info = new ProducerInfo(producerId); this.info = new ProducerInfo(producerId);
this.info.setWindowSize(session.connection.getProducerWindowSize()); this.info.setWindowSize(session.connection.getProducerWindowSize());
// Allows the options on the destination to configure the producerInfo
if (destination != null && destination.getOptions() != null) { if (destination != null && destination.getOptions() != null) {
Map<String, String> options = new HashMap<String, String>(destination.getOptions()); Map<String, String> options = new HashMap<String, String>(destination.getOptions());
IntrospectionSupport.setProperties(this.info, options, "producer."); IntrospectionSupport.setProperties(this.info, options, "producer.");
if (options.size() > 0) {
String msg = "There are " + options.size()
+ " producer options that couldn't be set on the producer."
+ " Check the options are spelled correctly."
+ " Unknown parameters=[" + options + "]."
+ " This producer cannot be started.";
LOG.warn(msg);
throw new ConfigurationException(msg);
} }
}
this.info.setDestination(destination); this.info.setDestination(destination);
// Enable producer window flow control if protocol > 3 and the window // Enable producer window flow control if protocol > 3 and the window