-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Receiver.java
37 lines (28 loc) · 884 Bytes
/
Receiver.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.vertx.example.reactivex.eventbus.zipreplies;
import io.vertx.core.Launcher;
import io.vertx.reactivex.core.AbstractVerticle;
import io.vertx.reactivex.core.eventbus.EventBus;
import java.util.Random;
/*
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class Receiver extends AbstractVerticle {
public static void main(String[] args) {
Launcher.executeCommand("run", Receiver.class.getName(), "-cluster");
}
@Override
public void start() throws Exception {
Random random1 = new Random();
EventBus eb = vertx.eventBus();
eb.consumer("heatsensor1").
toFlowable().
subscribe(message -> {
message.reply(9 + random1.nextInt(5));
});
eb.consumer("heatsensor2").
toFlowable().
subscribe(message -> {
message.reply(10 + random1.nextInt(3));
});
}
}