Skip to content

Commit c106b44

Browse files
committed
✨ done with webflux-flux&Mono ServersideEvent proj
ect, all done
1 parent 10259a9 commit c106b44

File tree

26 files changed

+996
-54
lines changed

26 files changed

+996
-54
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/data.csv
44
/unused
55

6+
/springbootResouces
7+
68
/.metadata/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
61.1 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Screenshots (Wait for 7-8 PNG files to load)
2+
3+
<img src="./Screenshots/ss3.gif" alt="Flux local DateTime">
4+
<img src="./Screenshots/ss2.png" alt="Mono local DateTime">
5+
<img src="./Screenshots/ss4.gif" alt="Flux Combining bookFlux & quoteFlux">
6+
<img src="./Screenshots/ss5.gif" alt="Flux filtering quoteFlux">
7+
<img src="./Screenshots/ss1.png" alt="Custom Error Page">
8+
9+
# Web-Flux & Mono Tutorials
10+
11+
This app gives <b>Flux and Mono</b> data from <b>HashMap</b> present in ./src/main/java/com/example/myWebFluxSSEApp/Data/ReactiveDataUtil.java and shows it in Flux and Mono. I have also <b>i. combined flux & ii. filtered & mapped flux</b>.
12+
13+
# Resources
14+
15+
1. https://www.baeldung.com/java-reactor-flux-vs-mono
16+
2. Java Brains
17+
18+
# Mono
19+
20+
Mono is a special type of Publisher. A Mono object represents a single or empty value.
21+
This means it can emit only one value at most for the onNext() request and then terminates
22+
23+
# Flux
24+
25+
Flux is a standard Publisher that represents 0 to N asynchronous sequence values. This means that it can emit 0 to many values, possibly infinite values for onNext() requests, and then terminates with either a completion or an error signal.
26+
27+
Mono and Flux are both implementations of the Publisher interface.
28+
29+
# Producer
30+
31+
In the context of reactive programming, a producer is a source of data that emits items asynchronously over time. It generates data and pushes it to consumers. For example, in the context of reactive streams, a producer could be a Flux that emits a sequence of items.
32+
33+
# Consumer
34+
35+
A consumer is a component that subscribes to a producer to receive and process the data it emits. It reacts to the data as it arrives. In reactive programming, a consumer is also referred to as a subscriber. It specifies what to do with the data and handles backpressure if the producer emits data faster than the consumer can process.
36+
37+
# Iterate
38+
39+
In the context of reactive programming, "iterate" generally refers to the process of sequentially processing items emitted by a producer using a consumer. It involves subscribing to a producer and reacting to each emitted item by performing some operation.
40+
41+
Here's a brief example of how these concepts could be applied in a reactive programming scenario using Spring WebFlux:
42+
43+
```
44+
Flux<Integer> producer = Flux.range(1, 10); // A producer that emits numbers from 1 to 10
45+
46+
Consumer<Integer> consumer = item -> {
47+
// Process each emitted item (number) here
48+
System.out.println("Received: " + item);
49+
};
50+
51+
producer.subscribe(consumer); // Subscribe the consumer to the producer
52+
```
53+
54+
In this example, producer is a source of data emitting numbers, and consumer is processing each emitted number. The subscribe method connects the producer with the consumer, initiating the flow of data.
55+
56+
Reactive programming focuses on handling asynchronous data streams, and the concepts of producers and consumers are fundamental to this paradigm. By using reactive constructs like Flux and Mono, you can build efficient and responsive applications that deal with asynchronous and event-driven scenarios.
449 KB
Loading
381 KB
Loading
2.86 MB
Loading
3.71 MB
Loading
5.67 MB
Loading

0 commit comments

Comments
 (0)