{"id":1400,"date":"2022-02-25T10:54:29","date_gmt":"2022-02-25T10:54:29","guid":{"rendered":"http:\/\/www.igfasouza.com\/blog\/?p=1400"},"modified":"2022-02-25T10:54:29","modified_gmt":"2022-02-25T10:54:29","slug":"so-wheres-the-difference-between-all-these-streams","status":"publish","type":"post","link":"http:\/\/www.igfasouza.com\/blog\/so-wheres-the-difference-between-all-these-streams\/","title":{"rendered":"So where\u2019s the difference between all these streams?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_stream_011.jpg\" alt=\"\" width=\"604\" height=\"294\" class=\"alignnone size-full wp-image-1401\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_stream_011.jpg 604w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_stream_011-300x146.jpg 300w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<p><b>How heya?<\/b><\/p>\n<p>What are the differences between Data Streams, Java Streams, Reactive Streams, Kafka Streams, Spark Streams, and several others Streams?<\/p>\n<p>The term stream does not really say much. A stream is simply a sequence of data elements made available over time. So the word stream does not imply any technical details, just that there is data and we can use it over time. It is a generic term that applies to Java Streams, Observables, and even Iterators. This blog might help to clarify your understanding of what the fuss is about.<\/p>\n<p>Let&#8217;s check one by one;<\/p>\n<h2>Data Streams<\/h2>\n<p>Data streaming is the ongoing transfer of data at a high rate of speed. Most data streams are continuously collecting data from thousands of data sources, and typically send large clusters of smaller-sized data records simultaneously.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/data_streams.jpg\" alt=\"\" width=\"353\" height=\"113\" class=\"alignnone size-full wp-image-1378\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/data_streams.jpg 353w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/data_streams-300x96.jpg 300w\" sizes=\"auto, (max-width: 353px) 100vw, 353px\" \/><br \/>\n<small>Picture 1: Data Streams<\/small><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/ds7tx5IF8GM\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<h2>Java Stream<\/h2>\n<p>From Java 8 streams are wrappers around a data source, allowing us to operate with that data source and making bulk processing convenient and fast. You can think of it as the API that you can use to manipulate data.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/java_streams_api.jpg\" alt=\"\" width=\"910\" height=\"406\" class=\"alignnone size-full wp-image-1380\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/java_streams_api.jpg 910w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/java_streams_api-300x135.jpg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/java_streams_api-768x343.jpg 768w\" sizes=\"auto, (max-width: 910px) 100vw, 910px\" \/><br \/>\n<small>Picture 2: Java Util Stream API<\/small><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/t1-YZ6bF-g0\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<h2>Reactive Streams<\/h2>\n<p>Flow API introduced in Java 9<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01.png\" alt=\"\" width=\"2700\" height=\"1377\" class=\"alignnone size-full wp-image-1393\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01.png 2700w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01-300x153.png 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01-1024x522.png 1024w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01-768x392.png 768w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01-1536x783.png 1536w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive_streams01-2048x1044.png 2048w\" sizes=\"auto, (max-width: 2700px) 100vw, 2700px\" \/><br \/>\n<small>Picture 3: Reactive Streams<\/small><\/p>\n<p>While the Streams API introduced in Java 8 is perfect to process data streams, map, reduce and all the variants, the Flow API introduced in Java 9 shines on the communication side request, slow down, drop, block, etc.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/vQ5fBF4Z0CQ\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>The main differences between the most common streams are following:<\/p>\n<ul>\n<li>\n<b>Java Streams<\/b<: pull-based and synchronous\n<\/li>\n<li>\n<b>Reactive Streams<\/b>: push-based and asynchronous\n<\/li>\n<\/ul>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/kG2SEcl1aMM\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<h2>Reactive programming<\/h2>\n<p>Reactive programming, if I try to shrink it to a paragraph, is a way of programming in which the consumers are in control of the Data Flow<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive-manifesto.png\" alt=\"\" width=\"536\" height=\"555\" class=\"alignnone size-full wp-image-1390\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive-manifesto.png 536w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/reactive-manifesto-290x300.png 290w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><br \/>\n<small>Picture 4: Reactive Manifesto<\/small><\/p>\n<p>There are 3 implementations in Java<\/p>\n<p><a href=\"https:\/\/www.reactive-streams.org\/\" target=\"_blank\" rel=\"noopener\">Reactive Streams<\/a><br \/>\n<a href=\"https:\/\/github.com\/ReactiveX\/RxJava\" target=\"_blank\" rel=\"noopener\">RxJava<\/a><br \/>\n<a href=\"https:\/\/projectreactor.io\/\" target=\"_blank\" rel=\"noopener\">Project Reactor<\/a><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/q2ynYUkVWnY\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<h2>Kafka Streams<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/kafka_streams.png\" alt=\"\" width=\"1327\" height=\"375\" class=\"alignnone size-full wp-image-1403\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/kafka_streams.png 1327w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/kafka_streams-300x85.png 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/kafka_streams-1024x289.png 1024w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/kafka_streams-768x217.png 768w\" sizes=\"auto, (max-width: 1327px) 100vw, 1327px\" \/><br \/>\n<small>Picture 5: Kafka Streams<\/small><\/p>\n<p>Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in an Apache Kafka cluster. It combines the simplicity of writing and deploying standard Java and Scala applications on the client-side with the benefits of Kafka&#8217;s server-side cluster technology.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/-y2ALVkU5Bc\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>I just realised that I don\u2019t have a blog post about Kafka Streams. Stay tuned for one soon.<\/p>\n<h2>Spark Streaming<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/sparkstreaming.jpg\" alt=\"\" width=\"680\" height=\"227\" class=\"alignnone size-full wp-image-1404\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/sparkstreaming.jpg 680w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/sparkstreaming-300x100.jpg 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><br \/>\n<small>Picture 6: Spark Streaming<\/small><\/p>\n<p>Spark Streaming is an extension of the core Spark API that allows data engineers and data scientists to process real-time data from various sources including (but not limited to) Kafka, Flume, and others. This processed data can be pushed out to file systems, databases, and live dashboards.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/dYBWZTZT6o0\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>I just realised that I don\u2019t have a blog post about Spark Streaming. Stay tuned for one soon.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/AliceBob.jpg\" alt=\"\" width=\"1222\" height=\"336\" class=\"alignnone size-full wp-image-1394\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/AliceBob.jpg 1222w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/AliceBob-300x82.jpg 300w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/AliceBob-1024x282.jpg 1024w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2022\/02\/AliceBob-768x211.jpg 768w\" sizes=\"auto, (max-width: 1222px) 100vw, 1222px\" \/><br \/>\n<small>Picture 7: Real example<\/small><\/p>\n<h2>Conclusion<\/h2>\n<p>The term stream does not really say much and it is used in several buzzwords at the moment.<br \/>\nThe main difference is about checking if it is pull-based or push-based and synchronous or asynchronous.<br \/>\nJava Streams came from Java 8 and Reactive Streams came from Java 9.<\/p>\n<p>Kafka and Spark Streams are just API name to do something similar to what Java Stream does.<\/p>\n<h2>Links<\/h2>\n<p><a href=\"http:\/\/www.igfasouza.com\/blog\/java-stream\/\" rel=\"noopener\" target=\"_blank\">http:\/\/www.igfasouza.com\/blog\/java-stream\/<\/a><\/p>\n<p><a href=\"http:\/\/www.igfasouza.com\/blog\/reactive-streams-and-reactive-programming\/\" rel=\"noopener\" target=\"_blank\">http:\/\/www.igfasouza.com\/blog\/reactive-streams-and-reactive-programming\/<\/a><\/p>\n<p><a href=\"http:\/\/www.igfasouza.com\/blog\/learn-kafka-and-event-streams-with-fun\/\" rel=\"noopener\" target=\"_blank\">http:\/\/www.igfasouza.com\/blog\/learn-kafka-and-event-streams-with-fun\/<\/a><\/p>\n<p><a href=\"http:\/\/www.igfasouza.com\/blog\/what-is-stream-processing\/\" rel=\"noopener\" target=\"_blank\">http:\/\/www.igfasouza.com\/blog\/what-is-stream-processing\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How heya? What are the differences between Data Streams, Java Streams, Reactive Streams, Kafka Streams, Spark Streams, and several others Streams? The term stream does not really say much. A stream is simply a sequence of data elements made available&hellip; <a href=\"http:\/\/www.igfasouza.com\/blog\/so-wheres-the-difference-between-all-these-streams\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1401,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[17],"class_list":["post-1400","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java"],"_links":{"self":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/1400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/comments?post=1400"}],"version-history":[{"count":4,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions"}],"predecessor-version":[{"id":1407,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions\/1407"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/media\/1401"}],"wp:attachment":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/media?parent=1400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/categories?post=1400"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/tags?post=1400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}