/** Entry point for a streaming Fizz Buzz! */ public static void main(String[] args) throws Exception { Topology topology = new Topology(); // Declare an infinite stream of Long values TStream<Long> counting = BeaconStreams.longBeacon(topology); // Throttle the rate to allow the output to be seen easier counting = counting.throttle(100, TimeUnit.MILLISECONDS); // Print the tuples to standard output playFizzBuzz(counting).print(); // At this point the streaming topology (streaming) is // declared, but no data is flowing. The topology // must be submitted to a StreamsContext to be executed. // Since this is an streaming graph with an endless // data source it will run for ever Future<?> runningTopology = StreamsContextFactory.getEmbedded().submit(topology); // Run for one minute before canceling. Thread.sleep(TimeUnit.MINUTES.toMillis(1)); runningTopology.cancel(true); }