<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:int="http://www.springframework.org/schema/integration"
		xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
		xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/integration/jms https://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
		http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd">

	<int:gateway id="explicitCorrelationKeyGateway" default-request-channel="explicitCorrelationIn"/>

	<int-jms:outbound-gateway request-channel="explicitCorrelationIn"
	    connection-factory="jmsConnectionFactory"
		request-destination="explicitCorrelationJmsOut"
		correlation-key="bar"/>

	<bean id="explicitCorrelationJmsOut" class="org.apache.activemq.artemis.jms.client.ActiveMQQueue">
		<constructor-arg value="explicitCorrelationJmsOut"/>
	</bean>

	<int-jms:inbound-gateway request-channel="requestIn"
	    request-destination="explicitCorrelationJmsOut"
	    correlation-key="bar"
		connection-factory="jmsConnectionFactory"/>

	<int:transformer input-channel="requestIn" expression="payload"/>

	<!--  -->

	<int:gateway id="explicitCorrelationKeyGatewayB" default-request-channel="explicitCorrelationInB"/>

	<int-jms:outbound-gateway request-channel="explicitCorrelationInB"
	    connection-factory="jmsConnectionFactory"
		request-destination="explicitCorrelationJmsOutB"
		correlation-key="JMSCorrelationID"/>

	<bean id="explicitCorrelationJmsOutB" class="org.apache.activemq.artemis.jms.client.ActiveMQQueue">
		<constructor-arg value="explicitCorrelationJmsOutB"/>
	</bean>

	<int-jms:inbound-gateway request-channel="requestInB"
							 request-destination="explicitCorrelationJmsOutB"
							 correlation-key="JMSCorrelationID"
							 connection-factory="jmsConnectionFactory"/>

	<int:transformer input-channel="requestInB" expression="payload"/>

	<!--  -->

	<int:gateway id="existingCorrelationKeyGatewayB" default-request-channel="existingCorrelationInB"/>

	<int-jms:outbound-gateway request-channel="existingCorrelationInB"
	    connection-factory="jmsConnectionFactory"
		request-destination="existingCorrelationJmsOutB"
		correlation-key="JMSCorrelationID*"/>

	<bean id="existingCorrelationJmsOutB" class="org.apache.activemq.artemis.jms.client.ActiveMQQueue">
		<constructor-arg value="existingCorrelationJmsOutB"/>
	</bean>

	<int-jms:inbound-gateway request-channel="requestExistingCorrelationInB"
							 request-destination="existingCorrelationJmsOutB"
							 correlation-key="JMSCorrelationID"
							 connection-factory="jmsConnectionFactory"/>

	<int:chain input-channel="requestExistingCorrelationInB" >
		<int:header-enricher>
			<int:header name="receivedCorrelationId" expression="headers['jms_correlationId']"/>
		</int:header-enricher>
		<int:transformer expression="payload"/>
	</int:chain>

	<!--  -->

	<int:gateway id="explicitCorrelationKeyGatewayC" default-request-channel="explicitCorrelationInC"/>

	<int-jms:outbound-gateway id="outGateway" request-channel="explicitCorrelationInC"
	    connection-factory="jmsConnectionFactory"
		request-destination="explicitCorrelationJmsOutC"
		reply-destination-name="explicitCorrelationJmsInC"
		correlation-key="foo"
		receive-timeout="100"/>

	<bean id="explicitCorrelationJmsOutC" class="org.apache.activemq.artemis.jms.client.ActiveMQQueue">
		<constructor-arg value="explicitCorrelationJmsOutC"/>
	</bean>

	<int-jms:inbound-gateway id="inGateway" request-channel="requestInC"
	    request-destination="explicitCorrelationJmsOutC"
	    correlation-key="foo"
		connection-factory="jmsConnectionFactory"/>

	<int:transformer input-channel="requestInC">
		<bean class="org.springframework.integration.jms.request_reply.RequestReplyScenariosWithCorrelationKeyProvidedTests.DelayedService"/>
	</int:transformer>

	<util:constant id="jmsConnectionFactory"
				   static-field="org.springframework.integration.jms.ActiveMQMultiContextTests.amqFactory"/>

</beans>
