Search code examples
apache-camelapache-servicemix

Apache Camel dynamic route based on file content


I am trying to use apache camel to route file content to activemq queue. I use camel to poll xml files from a specific folder then send its content to queue. My problem is I want to send the content to dynamic queue name based on the content value. For example :
The xml file content is

<name="queue1"/>

Then it means that this one need to send to queue named "queue1". How can I use the "queue1" dynamic value to the "to:" parameter in camel route spring dsl?

Thanks


Solution

  • I think the best way to do this is save that name to header like in this example: https://stackoverflow.com/a/9637840/3703819

    and then use Simple expression in Endpoint like this:

    <recipientList>
        <simple>activemq:queue:${headers.dest}</simple>
    </recipientList>