27
27
import org .slf4j .LoggerFactory ;
28
28
import reactor .core .publisher .DirectProcessor ;
29
29
import reactor .core .publisher .Flux ;
30
+ import reactor .core .publisher .FluxSink ;
30
31
import reactor .core .publisher .Mono ;
31
32
import reactor .core .publisher .MonoProcessor ;
32
33
@@ -40,7 +41,9 @@ public class TestDuplexConnection implements DuplexConnection {
40
41
41
42
private final LinkedBlockingQueue <Frame > sent ;
42
43
private final DirectProcessor <Frame > sentPublisher ;
44
+ private final FluxSink <Frame > sentFluxSink ;
43
45
private final DirectProcessor <Frame > received ;
46
+ private final FluxSink <Frame > receivedFluxSink ;
44
47
private final MonoProcessor <Void > onClose ;
45
48
private final ConcurrentLinkedQueue <Subscriber <Frame >> sendSubscribers ;
46
49
private volatile double availability = 1 ;
@@ -49,7 +52,9 @@ public class TestDuplexConnection implements DuplexConnection {
49
52
public TestDuplexConnection () {
50
53
sent = new LinkedBlockingQueue <>();
51
54
received = DirectProcessor .create ();
55
+ receivedFluxSink = received .serialize ().sink ();
52
56
sentPublisher = DirectProcessor .create ();
57
+ sentFluxSink = sentPublisher .serialize ().sink ();
53
58
sendSubscribers = new ConcurrentLinkedQueue <>();
54
59
onClose = MonoProcessor .create ();
55
60
}
@@ -65,7 +70,7 @@ public Mono<Void> send(Publisher<Frame> frames) {
65
70
.doOnNext (
66
71
frame -> {
67
72
sent .offer (frame );
68
- sentPublisher . onNext (frame );
73
+ sentFluxSink . next (frame );
69
74
})
70
75
.doOnError (throwable -> logger .error ("Error in send stream on test connection." , throwable ))
71
76
.subscribe (subscriber );
@@ -116,7 +121,7 @@ public Publisher<Frame> getSentAsPublisher() {
116
121
117
122
public void addToReceivedBuffer (Frame ... received ) {
118
123
for (Frame frame : received ) {
119
- this .received . onNext (frame );
124
+ this .receivedFluxSink . next (frame );
120
125
}
121
126
}
122
127
0 commit comments