You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2013/11/04 14:56:19 UTC
git commit: https://issues.apache.org/jira/browse/AMQ-4843 -
implement and test for composite virtual destinations - forwardTo
Updated Branches:
refs/heads/trunk 4ddbb8546 -> 4109b7905
https://issues.apache.org/jira/browse/AMQ-4843 - implement and test for composite virtual destinations - forwardTo
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/4109b790
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/4109b790
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/4109b790
Branch: refs/heads/trunk
Commit: 4109b790595339e92306f00056746034e5541417
Parents: 4ddbb85
Author: gtully <ga...@gmail.com>
Authored: Mon Nov 4 13:55:21 2013 +0000
Committer: gtully <ga...@gmail.com>
Committed: Mon Nov 4 13:55:21 2013 +0000
----------------------------------------------------------------------
.../plugin/RuntimeConfigurationBroker.java | 27 ++++++--------
.../src/main/resources/binding.xjb | 16 +++++++++
.../org/apache/activemq/VirtualDestTest.java | 38 +++++++++++++++++++-
.../virtualDestTest-add-composite-vd.xml | 36 +++++++++++++++++++
4 files changed, 100 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/4109b790/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java
index b541542..0d08faf 100644
--- a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java
+++ b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java
@@ -576,24 +576,19 @@ public class RuntimeConfigurationBroker extends BrokerFilter {
// deal with nested elements
for (Object nested : filter(dto, Object.class)) {
String elementName = nested.getClass().getSimpleName();
- if (elementName.endsWith("s")) {
- Method setter = findSetter(instance, elementName);
- if (setter != null) {
-
- List<Object> argument = new LinkedList<Object>();
- for (Object elementContent : filter(nested, Object.class)) {
- argument.add(fromDto(elementContent, inferTargetObject(elementContent)));
- }
- try {
- setter.invoke(instance, matchType(argument, setter.getParameterTypes()[0]));
- } catch (Exception e) {
- info("failed to invoke " + setter + " on " + instance, e);
- }
- } else {
- info("failed to find setter for " + elementName + " on :" + instance);
+ Method setter = findSetter(instance, elementName);
+ if (setter != null) {
+ List<Object> argument = new LinkedList<Object>();
+ for (Object elementContent : filter(nested, Object.class)) {
+ argument.add(fromDto(elementContent, inferTargetObject(elementContent)));
+ }
+ try {
+ setter.invoke(instance, matchType(argument, setter.getParameterTypes()[0]));
+ } catch (Exception e) {
+ info("failed to invoke " + setter + " on " + instance, e);
}
} else {
- info("unsupported mapping of element for non plural:" + elementName);
+ info("failed to find setter for " + elementName + " on :" + instance);
}
}
return instance;
http://git-wip-us.apache.org/repos/asf/activemq/blob/4109b790/activemq-runtime-config/src/main/resources/binding.xjb
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/main/resources/binding.xjb b/activemq-runtime-config/src/main/resources/binding.xjb
index b5a5334..6e786a5 100644
--- a/activemq-runtime-config/src/main/resources/binding.xjb
+++ b/activemq-runtime-config/src/main/resources/binding.xjb
@@ -96,6 +96,22 @@
<jxb:property name="Contents" />
</jxb:bindings>
+ <jxb:bindings node="xs:element[@name='compositeQueue']/xs:complexType/xs:choice">
+ <jxb:property name="Contents" />
+ </jxb:bindings>
+
+ <jxb:bindings node="xs:element[@name='compositeQueue']/xs:complexType/xs:choice/xs:choice/xs:element[@name='forwardTo']/xs:complexType/xs:sequence">
+ <jxb:property name="Contents" />
+ </jxb:bindings>
+
+ <jxb:bindings node="xs:element[@name='compositeTopic']/xs:complexType/xs:choice">
+ <jxb:property name="Contents" />
+ </jxb:bindings>
+
+ <jxb:bindings node="xs:element[@name='compositeTopic']/xs:complexType/xs:choice/xs:choice/xs:element[@name='forwardTo']/xs:complexType/xs:sequence">
+ <jxb:property name="Contents" />
+ </jxb:bindings>
+
<jxb:bindings node="xs:element[@name='authorizationPlugin']/xs:complexType/xs:choice">
<jxb:property name="Contents" />
</jxb:bindings>
http://git-wip-us.apache.org/repos/asf/activemq/blob/4109b790/activemq-runtime-config/src/test/java/org/apache/activemq/VirtualDestTest.java
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/test/java/org/apache/activemq/VirtualDestTest.java b/activemq-runtime-config/src/test/java/org/apache/activemq/VirtualDestTest.java
index e408afd..5c007a7 100644
--- a/activemq-runtime-config/src/test/java/org/apache/activemq/VirtualDestTest.java
+++ b/activemq-runtime-config/src/test/java/org/apache/activemq/VirtualDestTest.java
@@ -68,6 +68,17 @@ public class VirtualDestTest extends RuntimeConfigTestSupport {
assertSame("same instance", newValue, brokerService.getDestinationInterceptors()[0]);
}
+ @Test
+ public void testNewComposite() throws Exception {
+ final String brokerConfig = configurationSeed + "-new-composite-vd-broker";
+ applyNewConfig(brokerConfig, RuntimeConfigTestSupport.EMPTY_UPDATABLE_CONFIG);
+ startBroker(brokerConfig);
+ assertTrue("broker alive", brokerService.isStarted());
+
+ applyNewConfig(brokerConfig, configurationSeed + "-add-composite-vd", SLEEP);
+
+ exerciseCompositeQueue("VirtualDestination.CompositeQueue", "VirtualDestination.QueueConsumer");
+ }
@Test
public void testNewNoDefaultVirtualTopicSupport() throws Exception {
@@ -218,11 +229,15 @@ public class VirtualDestTest extends RuntimeConfigTestSupport {
}
private void exerciseVirtualTopic(String topic) throws Exception {
+ exerciseVirtualTopic("Consumer.A.", topic);
+ }
+
+ private void exerciseVirtualTopic(String prefix, String topic) throws Exception {
ActiveMQConnection connection = new ActiveMQConnectionFactory("vm://localhost").createActiveMQConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(session.createQueue("Consumer.A." + topic));
+ ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(session.createQueue(prefix + topic));
LOG.info("new consumer for: " + consumer.getDestination());
MessageProducer producer = session.createProducer(session.createTopic(topic));
final String body = "To vt:" + topic;
@@ -238,4 +253,25 @@ public class VirtualDestTest extends RuntimeConfigTestSupport {
connection.close();
}
+ private void exerciseCompositeQueue(String dest, String consumerQ) throws Exception {
+ ActiveMQConnection connection = new ActiveMQConnectionFactory("vm://localhost").createActiveMQConnection();
+ connection.start();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(session.createQueue(consumerQ));
+ LOG.info("new consumer for: " + consumer.getDestination());
+ MessageProducer producer = session.createProducer(session.createQueue(dest));
+ final String body = "To cq:" + dest;
+ producer.send(session.createTextMessage(body));
+ LOG.info("sent to: " + producer.getDestination());
+
+ Message message = null;
+ for (int i=0; i<10 && message == null; i++) {
+ message = consumer.receive(1000);
+ }
+ assertNotNull("got message", message);
+ assertEquals("got expected message", body, ((TextMessage) message).getText());
+ connection.close();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/4109b790/activemq-runtime-config/src/test/resources/org/apache/activemq/virtualDestTest-add-composite-vd.xml
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/test/resources/org/apache/activemq/virtualDestTest-add-composite-vd.xml b/activemq-runtime-config/src/test/resources/org/apache/activemq/virtualDestTest-add-composite-vd.xml
new file mode 100644
index 0000000..9783e2a
--- /dev/null
+++ b/activemq-runtime-config/src/test/resources/org/apache/activemq/virtualDestTest-add-composite-vd.xml
@@ -0,0 +1,36 @@
+<?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://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <broker xmlns="http://activemq.apache.org/schema/core" start="false" persistent="false" >
+ <plugins>
+ <runtimeConfigurationPlugin checkPeriod="1000"/>
+ </plugins>
+ <destinationInterceptors><virtualDestinationInterceptor><virtualDestinations>
+ <compositeQueue name="VirtualDestination.CompositeQueue">
+ <forwardTo>
+ <queue physicalName="VirtualDestination.QueueConsumer"/>
+ <topic physicalName="VirtualDestination.TopicConsumer"/>
+ </forwardTo>
+ </compositeQueue></virtualDestinations></virtualDestinationInterceptor></destinationInterceptors>
+ </broker>
+</beans>