Author: davsclaus
Date: Wed Sep 14 13:20:52 2011
New Revision: 1170599
URL: http://svn.apache.org/viewvc?rev=1170599&view=rev
Log:
AMQ-3498: Added support for using ActiveMQ Destination Options in the Camel
endpoint uris, by specifing the options with destination. prefix.
Added:
activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java
- copied, changed from r1170057,
activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml
- copied, changed from r1170057,
activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml
Modified:
activemq/trunk/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
Modified:
activemq/trunk/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java?rev=1170599&r1=1170598&r2=1170599&view=diff
==============================================================================
---
activemq/trunk/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
(original)
+++
activemq/trunk/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
Wed Sep 14 13:20:52 2011
@@ -16,6 +16,8 @@
*/
package org.apache.activemq.camel.component;
+import java.net.URISyntaxException;
+import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.activemq.ActiveMQConnectionFactory;
@@ -23,6 +25,9 @@ import org.apache.activemq.Service;
import org.apache.camel.CamelContext;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
import org.springframework.jms.connection.SingleConnectionFactory;
/**
@@ -131,6 +136,28 @@ public class ActiveMQComponent extends J
}
@Override
+ @SuppressWarnings("unchecked")
+ protected String convertPathToActualDestination(String path, Map<String,
Object> parameters) {
+ // support ActiveMQ destination options using the destination. prefix
+ // http://activemq.apache.org/destination-options.html
+ Map options = IntrospectionSupport.extractProperties(parameters,
"destination.");
+
+ String query;
+ try {
+ query = URISupport.createQueryString(options);
+ } catch (URISyntaxException e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ }
+
+ // if we have destination options then append them to the destination
name
+ if (ObjectHelper.isNotEmpty(query)) {
+ return path + "?" + query;
+ } else {
+ return path;
+ }
+ }
+
+ @Override
protected void doStart() throws Exception {
super.doStart();
if (isExposeAllQueues()) {
Copied:
activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java
(from r1170057,
activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java)
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java?p2=activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java&p1=activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java&r1=1170057&r2=1170599&rev=1170599&view=diff
==============================================================================
---
activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java
(original)
+++
activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java
Wed Sep 14 13:20:52 2011
@@ -17,25 +17,18 @@
*/
package org.apache.activemq.camel;
-import java.util.List;
-
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.EndpointInject;
import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
-import org.springframework.beans.factory.annotation.Autowired;
/**
*
*/
@ContextConfiguration
-public class SetHeaderTest extends AbstractJUnit38SpringContextTests {
- private static final transient Logger LOG =
LoggerFactory.getLogger(SetHeaderTest.class);
+public class CamelDestinationExclusiveConsumerTest extends
AbstractJUnit38SpringContextTests {
@Autowired
protected CamelContext camelContext;
@@ -44,17 +37,7 @@ public class SetHeaderTest extends Abstr
protected MockEndpoint expectedEndpoint;
public void testMocksAreValid() throws Exception {
- // lets add more expectations
expectedEndpoint.expectedMessageCount(1);
- expectedEndpoint.message(0).header("JMSXGroupID").isEqualTo("ABC");
-
MockEndpoint.assertIsSatisfied(camelContext);
-
- // lets dump the received messages
- List<Exchange> list = expectedEndpoint.getReceivedExchanges();
- for (Exchange exchange : list) {
- Object body = exchange.getIn().getBody();
- LOG.debug("Received: body: " + body + " of type: " +
ObjectHelper.className(body) + " on: " + exchange);
- }
}
}
Copied:
activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml
(from r1170057,
activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml)
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml?p2=activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml&p1=activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml&r1=1170057&r2=1170599&rev=1170599&view=diff
==============================================================================
---
activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml
(original)
+++
activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml
Wed Sep 14 13:20:52 2011
@@ -15,7 +15,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<!-- START SNIPPET: example -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
@@ -23,27 +22,22 @@
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
">
+ <!-- START SNIPPET: e1 -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file://src/test/data?noop=true"/>
- <to uri="activemq:testQ-input"/>
+ <to uri="activemq:queue:foo"/>
</route>
<route>
- <from uri="activemq:testQ-input"/>
- <process ref="groupIdInsertionProcessor"/>
- <to uri="activemq:testQ-output"/>
- </route>
- <route>
- <from uri="activemq:testQ-output"/>
+ <!-- use consumer.exclusive ActiveMQ destination option, notice we have
to prefix with destination. -->
+ <from
uri="activemq:foo?destination.consumer.exclusive=true&destination.consumer.prefetchSize=50"/>
<to uri="mock:results"/>
</route>
</camelContext>
-
- <bean id="groupIdInsertionProcessor"
class="org.apache.activemq.camel.SetGroupIdProcessor"/>
+ <!-- END SNIPPET: e1 -->
<bean id="connectionFactory"
class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
</bean>
</beans>
- <!-- END SNIPPET: example -->