activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1089033 - in /activemq/trunk/activemq-camel/src/test: java/org/apache/activemq/camel/CamelRedeliveryTest.java resources/org/apache/activemq/camel/CamelRedeliveryTest-context.xml
Date Tue, 05 Apr 2011 13:34:18 GMT
Author: gtully
Date: Tue Apr  5 13:34:18 2011
New Revision: 1089033

URL: http://svn.apache.org/viewvc?rev=1089033&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-2710 - extend example to show dynamic destination
determination based on the message original destination property

Modified:
    activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelRedeliveryTest.java
    activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelRedeliveryTest-context.xml

Modified: activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelRedeliveryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelRedeliveryTest.java?rev=1089033&r1=1089032&r2=1089033&view=diff
==============================================================================
--- activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelRedeliveryTest.java
(original)
+++ activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/CamelRedeliveryTest.java
Tue Apr  5 13:34:18 2011
@@ -25,8 +25,12 @@ import javax.jms.TextMessage;
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.RedeliveryPolicy;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.camel.CamelContext;
+import org.apache.camel.Handler;
+import org.apache.camel.RecipientList;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -83,4 +87,15 @@ public class CamelRedeliveryTest extends
         // came from camel
         assertTrue("redelivery marker header set, so came from camel", m.getBooleanProperty("CamelRedeliveryMarker"));
     }
+
+    public static class DestinationExtractor {
+
+        @RecipientList @Handler
+        public String routeTo(ActiveMQMessage body) throws Exception {
+            ActiveMQDestination originalDestination = new ActiveMQQueue("camelRedeliveryQ");
+            // or pull value from the message; body.getOriginalDestination();
+
+            return "activemq:" + originalDestination.getPhysicalName() + "?explicitQosEnabled=true&messageConverter=#messageConverter";
+        }
+    }
 }

Modified: activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelRedeliveryTest-context.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelRedeliveryTest-context.xml?rev=1089033&r1=1089032&r2=1089033&view=diff
==============================================================================
--- activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelRedeliveryTest-context.xml
(original)
+++ activemq/trunk/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelRedeliveryTest-context.xml
Tue Apr  5 13:34:18 2011
@@ -30,7 +30,10 @@
       <!--  delay redelivery by 1 second using schedualler, the determination 
               of the delay can come form a processor to make it as complicated as needed
-->
       <setHeader headerName="AMQ_SCHEDULED_DELAY"><constant>1000</constant></setHeader>
-      <to pattern="InOnly" uri="activemq:camelRedeliveryQ?explicitQosEnabled=true&amp;messageConverter=#messageConverter"/>
+
+      <!-- dynamically configure the destination based on the message -->
+      <to pattern="InOnly" uri="recipientListDestinationGenerator" />
+      <!-- to pattern="InOnly" uri="activemq:camelRedeliveryQ?explicitQosEnabled=true&amp;messageConverter=#messageConverter"/
-->
     </route>
   </camelContext>
 
@@ -39,6 +42,7 @@
   </bean>
   
   <bean id="messageConverter" class="org.apache.activemq.camel.converter.IdentityMessageReuseConverter"
/>
+  <bean id="recipientListDestinationGenerator" class="org.apache.activemq.camel.CamelRedeliveryTest$DestinationExtractor"
/>
 
 </beans>
         <!-- END SNIPPET: example -->



Mime
View raw message