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

	<context:component-scan base-package="org.springframework.integration.samples.errorhandling" />

	<poller default="true" fixed-delay="1000" max-messages-per-poll="1"/>

	<inbound-channel-adapter ref="partyHost"
		method="nextInvitation" channel="invitations" />

	<channel id="invitations">
		<queue capacity="100" />
	</channel>

	<chain input-channel="invitations">
		<header-enricher>
			<error-channel ref="failed-invitations" />
		</header-enricher>
		<service-activator ref="partyGuest" method="onInvitation" />
	</chain>

	<channel id="failed-invitations" />

	<chain input-channel="failed-invitations">
		<transformer ref="errorUnwrapper" />
		<service-activator ref="partyHost" method="onInvitationFailed" />
	</chain>

	<!--
		If you don't listen to the default error channel you risk losing track
		of exceptions, as they cannot be passed back to the sender in band. It
		is recommended to have a generic error handler in your configuration
		to prevent this.
	-->
	<stream:stderr-channel-adapter channel="errorChannel" append-newline="true" />

</beans:beans>