Adrian Ber
Adrian Ber

Reputation: 21380

Spring Integration Twitter - get latest tweets

How can I specify to a search-inbound-channel-adapter to poll only for the latest tweets. By latest tweets I mean tweets within x minutes/hours/days or from the last tweet polled.

I want to avoid receiving duplicate tweets.

Upvotes: 0

Views: 387

Answers (2)

mfisher
mfisher

Reputation: 506

The inbound Twitter adapters do keep track of the latest ID, so you should not see duplicates while it's running. However, the default implementation of the MetadataStore (the component responsible for tracking that) stores the metadata in memory only. Therefore, it's possible to receive duplicates after a restart. As of version 3.0, you can provide a "metadata-store" reference when configuring the adapter, and we now provide a RedisMetadataStore out of the box. Configuring an instance of that and referencing it from the adapter will ensure that the information about last tweet seen is stored in redis rather than a Map in-process.

For more info, see: http://docs.spring.io/spring-integration/docs/3.0.0.BUILD-SNAPSHOT/reference/html/twitter.html#twitter-inbound

Hope that helps.

-Mark

Upvotes: 1

Gary Russell
Gary Russell

Reputation: 174719

You won't get duplicates because the adapter keeps track of the id of the last tweet sent to the channel.

This information is stored in a MetadataStore by default, it's an in-memory store so won't survive a system restart.

You can configure a persistent metadata store - a simple file store (properties file) or, in 3.0 a Redis store is available.

See the documentation for more information

If you want to use more advanced search techniques, you can use the Twitter rest api with an http outbound gateway.

Upvotes: 1

Related Questions