Available as of Camel 2.10
The Twitter component enables the most useful features of the Twitter API by encapsulating Twitter4J. It allows direct, polling, or event-driven consumption of timelines, users, trends, and direct messages. Also, it supports producing messages as status updates or direct messages.
Twitter now requires the use of OAuth for all client application authentication. In order to use camel-twitter with your account, you'll need to create a new application within Twitter at https://dev.twitter.com/apps/new and grant the application access to your account. Finally, generate your access token and secret.
Maven users will need to add the following dependency to their pom.xml for this component:
The twitter component can be configured with the Twitter account settings which is mandatory to configure before using.
You can also configure these options directly in the endpoint.
The consumer key
The consumer secret
The access token
The access token secret
Rather than the endpoints returning a List through one single route exchange, camel-twitter creates one route exchange per returned object. As an example, if "timeline/home" results in five statuses, the route will be executed five times (one for each Status).
|streaming/user||event, polling||twitter4j.Status||Camel 2.16: To receive tweets from protected users and accounts.|
direct, event, or polling
Consumer Key. Can also be configured on the
Consumer Secret. Can also be configured on the
Access Token. Can also be configured on the
Access Token Secret. Can also be configured on the
Username, used for user timeline consumption, direct message production, etc.
'lat,lon;lat,lon;...' Bounding boxes, created by pairs of lat/lons. Can be used for streaming/filter
'foo1,foo2,foo3...' Can be used for search and streaming/filter. See Advanced search for keywords syntax for searching with for example OR.
'username,username...' Can be used for streaming/filter
Filter out old tweets, that has previously been polled. This state is stored in memory only, and based on last tweet id. Since Camel 2.11.0 The search producer supports this option
Camel 2.11.0: The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running.
Camel 2.11.0: The lang string ISO_639-1 which will be used for searching
Camel 2.11.0: Limiting number of results per page.
Camel 2.11.0: The number of pages result which you want camel-twitter to consume.
Camel 2.12.3: The http proxy host which can be used for the camel-twitter.
Camel 2.12.3: The http proxy port which can be used for the camel-twitter.
Camel 2.12.3: The http proxy user which can be used for the camel-twitter.
Camel 2.12.3: The http proxy password which can be used for the camel-twitter.
This header is used by the search producer to change the search key words dynamically.
Camel 2.11.0: This header can override the option of
Camel 2.11.0 This header can override the option of
Camel 2.11.0 This header can converrid the option of
All message bodies utilize objects provided by the Twitter4J API.
To create a status update within your Twitter profile, send this producer a String body.
To poll, every 5 sec., all statuses on your home timeline:
To search for all statuses with the keyword 'camel':
Searching using a producer with static keywords
Searching using a producer with dynamic keywords from header
In the bar header we have the keywords we want to search, so we can assign this value to the
See also the Twitter Websocket Example.