<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	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/twitter https://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:int="http://www.springframework.org/schema/integration"
	xmlns:int-twitter="http://www.springframework.org/schema/integration/twitter">

	<context:property-placeholder location="classpath:oauth.properties"/>

	<!-- As of Twitter API version 1.1, users must be authenticated to perform searches -->

	<bean id="twitterTemplate"
		class="org.springframework.social.twitter.api.impl.TwitterTemplate">
		<constructor-arg value="${twitter.oauth.consumerKey}" />
		<constructor-arg value="${twitter.oauth.consumerSecret}" />
		<constructor-arg value="${twitter.oauth.accessToken}" />
		<constructor-arg value="${twitter.oauth.accessTokenSecret}" />
	</bean>

	<int-twitter:search-inbound-channel-adapter id="searchAdapter" channel="sourceExtractor"
		query="springintegration OR springframework OR #grails" twitter-template="twitterTemplate">
		<int:poller fixed-rate="3000" max-messages-per-poll="5" />
	</int-twitter:search-inbound-channel-adapter>

	<int:transformer input-channel="sourceExtractor" output-channel="twitterOut" expression="payload.getText()"/>

	<int:logging-channel-adapter id="twitterOut" level="INFO"/>
</beans>
