<?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-kafka="http://www.springframework.org/schema/integration/kafka"
	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/kafka https://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd">

	<int-kafka:inbound-channel-adapter
			id="adapter1"
			consumer-factory="consumerFactory"
			consumer-properties="consumerProperties1"
			ack-factory="ackFactory"
			channel="inbound"
			message-converter="converter"
			payload-type="java.lang.String"
			raw-header="true"
			auto-startup="false">
		<int:poller fixed-delay="5000"/>
	</int-kafka:inbound-channel-adapter>

	<int-kafka:inbound-channel-adapter
			id="adapter2"
			consumer-factory="multiFetchConsumerFactory"
			consumer-properties="consumerProperties2"
			allow-multi-fetch="true"
			auto-startup="false"
			channel="inbound">
		<int:poller fixed-delay="5000"/>
	</int-kafka:inbound-channel-adapter>

	<bean id="consumerFactory" class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
		<constructor-arg>
			<map>
				<entry key="max.poll.records" value="1"/>
			</map>
		</constructor-arg>
	</bean>

	<bean id="consumerProperties1" class="org.springframework.kafka.listener.ConsumerProperties">
		<constructor-arg name="topics" value="topic1"/>
		<property name="groupId" value="group"/>
		<property name="clientId" value="client"/>
		<property name="consumerRebalanceListener" ref="rebal"/>
	</bean>

	<bean id="consumerProperties2" class="org.springframework.kafka.listener.ConsumerProperties">
		<constructor-arg name="topics" value="topic1, topic2"/>
		<property name="groupId" value="group"/>
	</bean>

	<bean id="multiFetchConsumerFactory" class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
		<constructor-arg>
			<map>
				<entry key="max.poll.records" value="10"/>
			</map>
		</constructor-arg>
	</bean>

	<bean id="ackFactory" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg
			value="org.springframework.integration.kafka.inbound.KafkaMessageSource$KafkaAckCallbackFactory"
			type="java.lang.Class"/>
	</bean>

	<int:channel id="inbound"/>

	<bean id="converter" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg value="org.springframework.kafka.support.converter.RecordMessageConverter"
						 type="java.lang.Class"/>
	</bean>

	<bean id="rebal" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg value="org.apache.kafka.clients.consumer.ConsumerRebalanceListener"
						 type="java.lang.Class"/>
	</bean>

</beans>
