-
Notifications
You must be signed in to change notification settings - Fork 78
/
StartMiddleTierServices.java
52 lines (43 loc) · 2.67 KB
/
StartMiddleTierServices.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package io.reactivex.lab.services;
import io.reactivex.lab.services.impls.BookmarksService;
import io.reactivex.lab.services.impls.GeoService;
import io.reactivex.lab.services.impls.MockService;
import io.reactivex.lab.services.impls.PersonalizedCatalogService;
import io.reactivex.lab.services.impls.RatingsService;
import io.reactivex.lab.services.impls.SocialService;
import io.reactivex.lab.services.impls.UserService;
import io.reactivex.lab.services.impls.VideoMetadataService;
import rx.Observable;
import com.netflix.eureka2.client.Eureka;
import com.netflix.eureka2.client.EurekaClient;
import com.netflix.eureka2.client.resolver.ServerResolver;
import com.netflix.eureka2.client.resolver.ServerResolvers;
public class StartMiddleTierServices {
public static void main(String... args) {
/* Eureka Server Config */
System.setProperty("reactivelab.eureka.server.host", StartEurekaServer.EUREKA_SERVER_HOST);
System.setProperty("reactivelab.eureka.server.read.port", String.valueOf(StartEurekaServer.EUREKA_SERVER_READ_PORT));
System.setProperty("reactivelab.eureka.server.write.port", String.valueOf(StartEurekaServer.EUREKA_SERVER_WRITE_PORT));
System.setProperty("eureka2.registration.heartbeat.intervalMillis", "3000"); // set lower for demo/playground purposes
/* Create a EurekaClient to be used by the services for registering for discovery */
ServerResolver.Server discoveryServer = new ServerResolver.Server(StartEurekaServer.EUREKA_SERVER_HOST, StartEurekaServer.EUREKA_SERVER_READ_PORT);
ServerResolver.Server registrationServer = new ServerResolver.Server(StartEurekaServer.EUREKA_SERVER_HOST, StartEurekaServer.EUREKA_SERVER_WRITE_PORT);
EurekaClient eurekaClient = Eureka.newClientBuilder(ServerResolvers.from(discoveryServer), ServerResolvers.from(registrationServer)).build();
/* what port we want to begin at for launching the services */
int startingPort = 9190;
if (args.length > 0) {
startingPort = Integer.parseInt(args[0]);
}
System.out.println("Starting services ...");
new MockService(eurekaClient).start(startingPort);
new BookmarksService(eurekaClient).start(++startingPort);
new GeoService(eurekaClient).start(++startingPort);
new PersonalizedCatalogService(eurekaClient).start(++startingPort);
new RatingsService(eurekaClient).start(++startingPort);
new SocialService(eurekaClient).start(++startingPort);
new UserService(eurekaClient).start(++startingPort);
new VideoMetadataService(eurekaClient).start(++startingPort);
// block forever
Observable.never().toBlocking().single();
}
}