Class TwitterProxy

All Implemented Interfaces:
Runnable, Flow.Publisher<com.twitter.clientlib.model.Tweet>

public class TwitterProxy extends OfflineTweetsProducer
Acts as a proxy to Twitter changes web stream for a Kafka-based application: Reads the stream of Tweets flow and writes them to a Kafka topic.
  • Constructor Details

    • TwitterProxy

      public TwitterProxy(String fileName, String bootstrapServers, String topicName)
      Class constructor : Creates a web stream listener and a Kafka producer, the producer publishes to the Kafka topic the events received from the web stream (until it is interrupted).
      Parameters:
      fileName - name of the file containing tweets to send to kafka.
      bootstrapServers - Kafka servers.
      topicName - Tweets topic name.
  • Method Details

    • main

      public static void main(String[] args)
      Creates the proxy (provoking infinite execution).
      Parameters:
      args - first argument is the file name, second argument is a list of Kafka bootstrap servers, third argument is the name of the destination Kafka topic
    • run

      public void run()
    • onClosed

      public void onClosed() throws Exception
      Called if session closed.
      Throws:
      Exception - exception in case of error.
    • onOpen

      public void onOpen() throws Exception
      Called if session opened.
      Throws:
      Exception - throw exception.
    • onComment

      public void onComment(String comment) throws Exception
      Called if comment.
      Parameters:
      comment - Commentaire reçu (n'importe quelle ligne commençant par deux-points).
      Throws:
      Exception - Exception en cas d'erreur.
    • onError

      public void onError(Throwable t)
      Called if error.
      Parameters:
      t - represent error.