<?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:amqp="http://www.springframework.org/schema/integration/amqp"
	xmlns:int="http://www.springframework.org/schema/integration"
	xmlns:rabbit="http://www.springframework.org/schema/rabbit"
	xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp https://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
		http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/rabbit https://www.springframework.org/schema/rabbit/spring-rabbit.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">

	<amqp:outbound-gateway id="rabbitGateway" request-channel="toRabbit0"
		reply-channel="fromRabbit"
		reply-timeout="777"
		exchange-name="si.test.exchange"
		routing-key="si.test.binding"
		amqp-template="amqpTemplate"
		delay-expression="42"
		auto-startup="false"
		order="5"
		return-channel="returnChannel"
		error-message-strategy="ems">
		<int:poller fixed-delay="100"/>
	</amqp:outbound-gateway>

	<bean id="ems" class="org.springframework.integration.support.DefaultErrorMessageStrategy" />

	<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"/>

	<bean id="connectionFactory" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg value="org.springframework.amqp.rabbit.connection.ConnectionFactory" type="java.lang.Class"/>
	</bean>

	<int:channel id="toRabbit0">
		<int:queue/>
	</int:channel>
	<int:channel id="toRabbit1"/>
	<int:channel id="toRabbit2"/>
	<int:channel id="toRabbit3"/>
	<int:channel id="toRabbit4"/>

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

	<amqp:outbound-gateway id="withHeaderMapperCustomRequestResponse" request-channel="toRabbit1"
		reply-channel="fromRabbit"
		exchange-name="si.test.exchange"
		routing-key="si.test.binding"
		amqp-template="amqpTemplate"
		lazy-connect="false"
		order="5"
		default-delivery-mode="NON_PERSISTENT"
		requires-reply="false"
		headers-last="true"
		mapped-request-headers="foo*"
		mapped-reply-headers="bar*"/>

	<amqp:outbound-gateway id="withHeaderMapperCustomAndStandardResponse" request-channel="toRabbit2"
		reply-channel="fromRabbit"
		exchange-name="si.test.exchange"
		routing-key="si.test.binding"
		amqp-template="amqpTemplate"
		order="5"
		mapped-request-headers="foo*"
		mapped-reply-headers="bar*, STANDARD_REPLY_HEADERS"/>

	<amqp:outbound-gateway id="withHeaderMapperNothingToMap" request-channel="toRabbit3"
		reply-channel="fromRabbit"
		exchange-name="si.test.exchange"
		routing-key="si.test.binding"
		amqp-template="amqpTemplate"
		order="5"
		mapped-request-headers=""
		mapped-reply-headers="">
		<amqp:request-handler-advice-chain>
			<bean class="org.springframework.integration.amqp.config.AmqpOutboundGatewayParserTests$FooAdvice" />
		</amqp:request-handler-advice-chain>
	</amqp:outbound-gateway>

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

	<int:chain id="chainWithRabbitOutboundGateway" input-channel="toRabbit4" output-channel="fromRabbit">
		<amqp:outbound-gateway exchange-name="si.test.exchange"
							   routing-key="si.test.binding"
							   amqp-template="amqpTemplate"
							   mapped-request-headers=""
							   mapped-reply-headers=""/>
	</int:chain>

	<amqp:outbound-async-gateway id="asyncGateway" request-channel="toRabbit0"
		reply-channel="fromRabbit"
		reply-timeout="777"
		requires-reply="false"
		exchange-name="si.test.exchange"
		routing-key="si.test.binding"
		async-template="asyncTemplate"
		delay-expression="42"
		auto-startup="false"
		order="5"
		return-channel="returnChannel">
		<int:poller fixed-delay="100"/>
	</amqp:outbound-async-gateway>

	<bean id="asyncTemplate" class="org.springframework.amqp.rabbit.AsyncRabbitTemplate">
		<constructor-arg>
			<bean class="org.springframework.amqp.rabbit.core.RabbitTemplate">
				<constructor-arg ref="connectionFactory" />
			</bean>
		</constructor-arg>
		<constructor-arg>
			<bean class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer">
				<constructor-arg ref="connectionFactory" />
				<property name="queueNames" value="replies" />
			</bean>
		</constructor-arg>
	</bean>

</beans>
