19
19
import org .springframework .web .reactive .socket .client .StandardWebSocketClient ;
20
20
import org .springframework .web .reactive .socket .client .WebSocketClient ;
21
21
import reactor .core .publisher .Mono ;
22
+ import reactor .core .scheduler .Schedulers ;
22
23
23
24
import java .net .URI ;
24
25
import java .util .Map ;
@@ -65,8 +66,8 @@ public void metricsMapOneUserTwoConnections() {
65
66
CountDownLatch connectionLatch = new CountDownLatch (2 );
66
67
CountDownLatch assertLatch = new CountDownLatch (1 );
67
68
68
- Mono <Void > connection1 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch )));
69
- Mono <Void > connection2 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch )));
69
+ Mono <Void > connection1 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch ))). subscribeOn ( Schedulers . boundedElastic ()) ;
70
+ Mono <Void > connection2 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch ))). subscribeOn ( Schedulers . boundedElastic ()) ;
70
71
71
72
CompletableFuture <Void > evaluationFuture = evaluateAssert (connectionLatch , exp , assertLatch );
72
73
Mono .zip (connection1 , connection2 ).block ();
@@ -84,14 +85,14 @@ public void metricsMapTwoUsers() {
84
85
Map <String , Double > exp = Map .of (user1 , 2d , user2 , 1d );
85
86
CountDownLatch connectionLatch = new CountDownLatch (3 );
86
87
CountDownLatch assertLatch = new CountDownLatch (1 );
87
- Mono <Void > connection1 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch )));
88
- Mono <Void > connection2 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch )));
88
+ Mono <Void > connection1 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch ))). subscribeOn ( Schedulers . boundedElastic ()) ;
89
+ Mono <Void > connection2 = client1 .execute (getUrl ("/notify" ), httpHeaders1 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch ))). subscribeOn ( Schedulers . boundedElastic ()) ;
89
90
90
91
// Second WebSocketClient for connections related to 'test1' user
91
92
WebSocketClient client2 = new StandardWebSocketClient ();
92
93
HttpHeaders httpHeaders2 = new HttpHeaders ();
93
94
httpHeaders2 .add (HEADER_USER_ID , user2 );
94
- Mono <Void > connection3 = client2 .execute (getUrl ("/notify" ), httpHeaders2 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch )));
95
+ Mono <Void > connection3 = client2 .execute (getUrl ("/notify" ), httpHeaders2 , ws -> Mono .fromRunnable (() -> handleLatches (connectionLatch , assertLatch ))). subscribeOn ( Schedulers . boundedElastic ()) ;
95
96
96
97
CompletableFuture <Void > evaluationFuture = evaluateAssert (connectionLatch , exp , assertLatch );
97
98
Mono .zip (connection1 , connection2 , connection3 ).block ();
0 commit comments