O'Reilly logo

Real-Time Big Data Analytics by Shilpi Saxena, Sumit Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coding our first Spark Streaming job

In this section, we will code and execute our first Spark Streaming job in Scala. We will also simulate the streaming data by creating a temporary stream.

Creating a stream producer

Perform the following steps to create a stream producer which continuously reads the input data provided by the user from the console and then further submits that data to a socket:

  1. Open and edit your Spark-Examples project and create a new Scala package and class named chapter.nine.StreamProducer.java.
  2. Next, edit StreamProducer.java and add the following piece of code:
    import java.net.*; import java.io.*; public class StreamProducer { public static void main(String[] args) { if (args == null || args.length < 1) { System.out.println("Usage ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required