mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-2710 - extend example to show dynamic destination determination based on the message original destination property
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1089033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ebdadabc9
commit
2327e3975b
|
@ -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 AbstractJUnit38SpringContextTests {
|
|||
// 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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&messageConverter=#messageConverter"/>
|
||||
|
||||
<!-- dynamically configure the destination based on the message -->
|
||||
<to pattern="InOnly" uri="recipientListDestinationGenerator" />
|
||||
<!-- to pattern="InOnly" uri="activemq:camelRedeliveryQ?explicitQosEnabled=true&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 -->
|
||||
|
|
Loading…
Reference in New Issue