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

	<context:mbean-export/>

	<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>

	<int-jmx:mbean-export default-domain="#{@domain}" />

	<bean id="domain" class="java.lang.String">
		<constructor-arg value="#{T(java.util.UUID).randomUUID().toString()}"/>
	</bean>

	<int-jmx:tree-polling-channel-adapter id="adapter"
		channel="in"
		query-expression="#{domain}:type=MessageChannel,name=*"
		auto-startup="false">
		<int:poller max-messages-per-poll="1" fixed-rate="5000"/>
		<bean class="org.springframework.integration.jmx.DefaultMBeanObjectConverter">
			<constructor-arg>
				<bean class="org.springframework.integration.jmx.NamedFieldsMBeanAttributeFilter">
					<constructor-arg>
						<array>
							<value type="java.lang.String">QueueSize</value>
							<value type="java.lang.String">RemainingCapacity</value>
						</array>
					</constructor-arg>
				</bean>
			</constructor-arg>
		</bean>
	</int-jmx:tree-polling-channel-adapter>

	<int:channel id="in" />

	<int:service-activator id="pass"
		input-channel="in"
		output-channel="out"
		expression="payload">
	</int:service-activator>

	<int:channel id="out">
		<int:queue capacity="10" />
	</int:channel>

	<int-jmx:tree-polling-channel-adapter id="adapterNot"
		channel="in"
		query-expression="#{domain}:type=MessageChannel,name=*"
		auto-startup="false">
		<int:poller max-messages-per-poll="1" fixed-rate="5000"/>
		<bean class="org.springframework.integration.jmx.DefaultMBeanObjectConverter">
			<constructor-arg>
				<bean class="org.springframework.integration.jmx.NotNamedFieldsMBeanAttributeFilter">
					<constructor-arg>
						<array>
							<value type="java.lang.String">SendCount</value>
							<value type="java.lang.String">SendCountLong</value>
							<value type="java.lang.String">SendErrorCount</value>
							<value type="java.lang.String">SendErrorCountLong</value>
							<value type="java.lang.String">CountsEnabled</value>
							<value type="java.lang.String">StatsEnabled</value>
						</array>
					</constructor-arg>
				</bean>
			</constructor-arg>
		</bean>
	</int-jmx:tree-polling-channel-adapter>

</beans>
