Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed6f760

Browse files
Web Functions
1 parent 641e0af commit ed6f760

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.demo;
2+
3+
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
@AllArgsConstructor
10+
@NoArgsConstructor
11+
@Data
12+
@Builder
13+
public class TollRecord {
14+
private String stationId;
15+
private String licensePlate;
16+
private String timestamp;
17+
}

‎7.creating-functions/web-functions/src/main/java/com/example/demo/WebFunctionsApplication.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.context.annotation.Bean;
6+
import reactor.core.publisher.Flux;
7+
import reactor.core.publisher.Mono;
68

9+
import javax.management.Query;
710
import java.util.ArrayList;
811
import java.util.List;
12+
import java.util.function.Consumer;
913
import java.util.function.Function;
14+
import java.util.function.Supplier;
1015

1116
@SpringBootApplication
1217
public class WebFunctionsApplication {
@@ -34,4 +39,33 @@ public Function<String, TollStation> getStation(){
3439
.orElse(null);
3540
};
3641
}
42+
43+
@Bean
44+
public Consumer<TollRecord> processTollRecord(){
45+
return value -> {
46+
System.out.println("Received toll for each car with the license plate : "
47+
+value.getLicensePlate());
48+
};
49+
}
50+
51+
@Bean
52+
public Function<TollRecord, Mono<Void>> processTollRecordReactive(){
53+
return value -> {
54+
System.out.println("Received reactive toll for each car with the license plate : "
55+
+value.getLicensePlate());
56+
return Mono.empty();
57+
};
58+
}
59+
60+
@Bean
61+
public Consumer<Flux<TollRecord>> processListOfTollRecordsReactive(){
62+
return value -> {
63+
value.subscribe(toll -> System.out.println(toll.getLicensePlate()));
64+
};
65+
}
66+
67+
@Bean
68+
public Supplier<Flux<TollStation>> getTollStations(){
69+
return () -> Flux.fromIterable(tollStations);
70+
}
3771
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /