Permalink
Find file
f9ce4ee Feb 18, 2014
60 lines (50 sloc) 2.73 KB
<?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-mqtt="http://www.springframework.org/schema/integration/mqtt"
xmlns:twitter="http://www.springframework.org/schema/integration/twitter"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/mqtt http://www.springframework.org/schema/integration/mqtt/spring-integration-mqtt.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
<!-- these elements define a flow Twitter search->transform->MQTT publish -->
<!-- referred to as "outbound" in the README -->
<twitter:search-inbound-channel-adapter id="tweets"
query="#mqtt"
twitter-template="twitterTemplate">
<int:poller fixed-rate="5000" />
</twitter:search-inbound-channel-adapter>
<int:transformer
input-channel="tweets"
expression="'@' + payload.fromUser + ': ' + payload.text"
output-channel="mqtt-publish" />
<int-mqtt:outbound-channel-adapter id="mqtt-publish"
client-id="spring-foo-1"
client-factory="clientFactory"
auto-startup="true"
url="tcp://iot.eclipse.org:1883"
default-qos="0"
default-retained="true"
default-topic="tweets/spring-integration" />
<!-- these elements define a flow MQTT subscribe->transform->File -->
<!-- referred to as "inbound" in the README -->
<int-mqtt:message-driven-channel-adapter id="oneTopicAdapter"
client-id="spring-foo-2"
client-factory="clientFactory"
auto-startup="true"
url="tcp://iot.eclipse.org:1883"
topics="inbound/#"
send-timeout="123" />
<int:transformer id="convert"
input-channel="oneTopicAdapter"
expression="@tstamp + ' ' + headers.get('mqtt_topic') + ': ' + payload.toString() + @newline"
output-channel="to-file" />
<file:outbound-channel-adapter id="to-file"
mode="APPEND"
charset="UTF-8"
directory="./si"
filename-generator-expression="'MQTT-INPUT'" />
</beans>