<?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: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:channel id="receiveChannel">
		<int:queue/>
	</int:channel>

	<int:chain input-channel="outboundChainChannel">
		<jms:outbound-channel-adapter destination="testQueue"/>
	</int:chain>

	<int:channel id="repliesChannel">
		<int:queue/>
	</int:channel>

	<int:chain input-channel="outboundGatewayChainChannel" output-channel="repliesChannel">
		<jms:outbound-gateway request-destination="testQueue2" receive-timeout="1000" requires-reply="false"/>
	</int:chain>


	<jms:message-driven-channel-adapter destination="testQueue" channel="receiveChannel"/>

	<jms:inbound-gateway request-channel="inboundJmsChannel" request-destination="testQueue2"/>

	<bean id="jmsRequiresReplyFlag" class="java.util.concurrent.atomic.AtomicInteger"/>

	<int:chain input-channel="inboundJmsChannel">
		<int:service-activator expression="@jmsRequiresReplyFlag.getAndIncrement() % 2 == 0 ? payload : null"/>
	</int:chain>

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

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

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

</beans>
