How do I dynamically generate file name based on XML message body in a Camel route at runtime
Issue
Background
I have a Camel route to route a message from an ActiveMQ queue to a file:
<route>
<from uri="activemq:queue:DATA.OUT"/>
<to uri="file:/opt/data/DATA.OUT"/>
</route>
There is a requirement to dynamically look up the value of two elements in an XML message and create a file name based on the value of those two elements. For example, the message might look like:
<?xml version='1.0' encoding='UTF-8'?>
<tst_msg>
<product_header>
<product_header_msg_id>
<product_msg_id>9840</product_msg_id>
<product_msg_name>Test Product</product_msg_name>
</product_header_msg_id>
</product_header>
<packet_header>
<packet_header_index>1</packet_header_index>
<packet_header_msg_number>8491920</packet_header_msg_number>
<packet_header_size>944</packet_header_size>
</packet_header>
</tst_msg>
The resulting file name should be something like: tst-msg-file-8491920-9840-data.xml.
Environment
- Fuse Mediation Router 2.8
- Fuse Mediation Router 2.9
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
