mirror of https://github.com/apache/activemq.git
AMQ-3498: Added support for using ActiveMQ Destination Options in the Camel endpoint uris, by specifing the options with destination. prefix.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1170599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba0c1e59b2
commit
5cf4ada14a
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.camel.component;
|
package org.apache.activemq.camel.component;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
|
@ -23,6 +25,9 @@ import org.apache.activemq.Service;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.apache.camel.component.jms.JmsComponent;
|
import org.apache.camel.component.jms.JmsComponent;
|
||||||
import org.apache.camel.component.jms.JmsConfiguration;
|
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;
|
import org.springframework.jms.connection.SingleConnectionFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,6 +135,28 @@ public class ActiveMQComponent extends JmsComponent {
|
||||||
singleConnectionFactoryList.add(singleConnectionFactory);
|
singleConnectionFactoryList.add(singleConnectionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
protected void doStart() throws Exception {
|
protected void doStart() throws Exception {
|
||||||
super.doStart();
|
super.doStart();
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.camel;
|
||||||
|
|
||||||
|
import org.apache.camel.CamelContext;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ContextConfiguration
|
||||||
|
public class CamelDestinationExclusiveConsumerTest extends AbstractJUnit38SpringContextTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CamelContext camelContext;
|
||||||
|
|
||||||
|
@EndpointInject(uri = "mock:results")
|
||||||
|
protected MockEndpoint expectedEndpoint;
|
||||||
|
|
||||||
|
public void testMocksAreValid() throws Exception {
|
||||||
|
expectedEndpoint.expectedMessageCount(1);
|
||||||
|
MockEndpoint.assertIsSatisfied(camelContext);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
|
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:queue:foo"/>
|
||||||
|
</route>
|
||||||
|
<route>
|
||||||
|
<!-- 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>
|
||||||
|
<!-- END SNIPPET: e1 -->
|
||||||
|
|
||||||
|
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
|
||||||
|
<property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
Loading…
Reference in New Issue