[#ftl attributes={"generated.type":"blueprint"}]
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <reference id="entaxy-broker" interface="org.apache.camel.Component"
               filter="(connection.name=entaxy-broker)"/>

    <camelContext id="route-[=systemName]" xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="direct-vm:profile-[=systemName]-exit-point"/>
            <log message="Message ${headers} send to route" loggingLevel="TRACE"/>

            <when>
                <simple>${headers.ENTAXY_Destination} == 'nsi'
                    &amp;&amp; ${headers.ENTAXY_DestinationType} == null
                </simple>
                <setHeader name="NTX_NSI_Answer">
                    <simple>true</simple>
                </setHeader>
                <to uri="entaxy-broker:queue:entaxy.nsi.entry.point?exchangePattern=InOnly"/>
            </when>

            <choice>
                <when>
                    <simple>${headers.ENTAXY_DestinationType} == 'system.name'</simple>
                    <toD uri="system:${headers.ENTAXY_Destination}"/>
                </when>
                <when>
                    <simple>${headers.ENTAXY_DestinationType} == 'system-group.name'</simple>
                    <toD uri="system-group:${headers.ENTAXY_Destination}"/>
                </when>
                <when>
                    <simple>${headers.ENTAXY_DestinationType} == 'queue.name'</simple>
                    <toD uri="entaxy-broker:queue:${headers.ENTAXY_Destination}"/>
                </when>
                <when>
                    <simple>${headers.ENTAXY_DestinationType} == 'topic.name'</simple>
                    <toD uri="entaxy-broker:topic:${headers.ENTAXY_Destination}"/>
                </when>
                <otherwise>
                    <toD uri="system:${headers.ENTAXY_Destination}"/>
                </otherwise>
            </choice>
        </route>
    </camelContext>
</blueprint>
