2
votes

I'm considering the use of camel-twitter (The Twitter Component for Apache Camel: http://camel.apache.org/twitter.html). I want to use Twitters Streaming API.

What is the difference between the types event and direct?

Does somebody have an example code for the usage of the event-driven consumer? (I only found this one so far https://fisheye6.atlassian.com/browse/camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchEventTest.java)

3

3 Answers

1
votes

direct means that you do an explict direct call to trigger twitter. For example using the direct component in Camel to call a route with twitter.

event means event driven consumer, where you have twitter react on events, such as new tweets found in a search etc.

And for examples, we have also this websocket twitter example: http://camel.apache.org/twitter-websocket-example.html

1
votes

Keep in mind that the Streaming API cannot be used with the direct endpoint -- only event and polling are supported.

From an API usage standpoint, both event and polling work identically. A single stream listener is opened and maintained. Rate limit considerations do not differ.

The only difference is that the event endpoint sends 1 event per message, immediately when it's received. Polling queues up the received messages and releases them on each poll.

So, the differences are purely how they're delivered inside of Camel. With respect to the API, both streaming endpoints are the same.

0
votes

The Direct type tells the consumer/producer that it will connect to Twitter each time the endpoint is activated somehow. Let's say you want to use a schedule saved in your database to do searches on Twitter:

  1. Use a JDBC/JPA endpoint that consumes scheduling data
  2. Dynamically create and register Quartz endpoints based on the scheduling data from your DB
  3. Configure your Quartz endpoint to send a message to your Direct Twitter endpoint to do the search at that moment

You will be rated, always. No matter if you use Streaming, Direct, or Polling. In case you are using Streaming, please read this FAQ from Twitter Developer Center