Nav

Example: Dynamic Routing with the VM Connector

You can use expressions to have a generic flow that sends messages to different queues depending on certain conditions. For instance, you can make the publish and listen example more interesting by also using an expression in the queueName attribute.

Suppose that the JSON object that you get through the HTTP connector includes a destination object that maps directly to the name of the queue to which you need to write. You can do the following:


       
    
1
2
3
4
5
6
7
    <flow name="publish">
        <http:listener path="/json-here" allowedMethods="POST" config-ref="httpListener" />
        <vm:publish queueName="#[payload.destination]">
            <vm:content>#[payload.body]</vm:content>
        </vm:publish>
        <logger/>
    </flow>