[#ftl attributes={"generated.type":"blueprint.fragment"}]
		<bean id="uuidGenerator" class="java.util.UUID" scope="prototype" factory-method="randomUUID"/>

		<route id="[=properties.connectorId].root-route">
			<from uri="direct:exit-cascade-start" />
			<to uri="direct:set-default-destination" />
			<to uri="bean:[=properties.connectorId].metadataEnricher" />
			<to uri="direct:pre-route" />
			<when>
				<simple>${headers.ENTAXY_MessageUUID} == null</simple>
				<setHeader name="ENTAXY_MessageUUID">
					<simple>${bean:uuidGenerator.toString}</simple>
				</setHeader>
			</when>			
			<choice>
				<when>
					<simple>${headers.NTX_RESPOND_now} == 'true'</simple>
					<choice>
						<when>
							<simple>${headers.NTX_RESPOND_continue} == 'true'</simple>
							<choice>
								<when>
									<simple>${headers.NTX_RESPOND_continueAsync} == 'true'</simple>
									<removeHeaders pattern="NTX_RESPOND_.+" />
									<!-- multicast shareUnitOfWork="true" -->
										<to uri="seda:[=properties.connectorId].root-route-output-async" />
									[#if properties.processResponse]
										<to uri="direct:connector-[=properties.connectorId]-response-route" />
									[/#if]	
									<removeHeaders pattern="NTX_.+" />
									<!-- /multicast -->
								</when>
								<otherwise>
									<removeHeaders pattern="NTX_RESPOND_.+" />
									<multicast shareUnitOfWork="true">
									[#if properties.processResponse]
										<to uri="direct:connector-[=properties.connectorId]-response-route" />
									[/#if]	
										<to uri="direct:[=properties.connectorId].root-route-output" />
									</multicast>	
								</otherwise>	
							</choice>							
						</when>
						[#if properties.processResponse]
						<otherwise>
							<removeHeaders pattern="NTX_RESPOND_.+" />
							<to uri="direct:connector-[=properties.connectorId]-response-route" />
						</otherwise>	
						[/#if]	
					</choice>
				</when>
				<otherwise>
					<to uri="direct:[=properties.connectorId].root-route-output" />
				</otherwise>
			</choice>
		</route>
		<route id="[=properties.connectorId].root-route-output-async">
			<from uri="seda:[=properties.connectorId].root-route-output-async" />
			<setExchangePattern pattern="InOnly" />
			<to uri="direct:[=properties.connectorId].root-route-output" />
		</route>
		<route id="[=properties.connectorId].root-route-output">
			<from uri="direct:[=properties.connectorId].root-route-output" />
			<to uri="direct-vm:profile-[=properties.profile]-in-flow" />
		[#if properties.processResponse]
			<to uri="direct:connector-[=properties.connectorId]-response-route" />
		[/#if]	
			<removeHeaders pattern="NTX_.+" />
		</route>

		<route id="[=properties.connectorId].default-destination-route">
			<from uri="direct:set-default-destination" />
			[#if properties.defaultDestination?? && properties.defaultDestination?is_string]
			<when>
				<simple>${headers.ENTAXY_Destination} == null || ${headers.ENTAXY_Destination} == ''</simple>
				<setHeader name="ENTAXY_Destination">
					<constant>[=properties.defaultDestination]</constant>
				</setHeader>
			</when>
			[/#if]
			<log loggingLevel="DEBUG" message="Destination is: ${header.ENTAXY_Destination}"/>
		</route>
