@@ -77,41 +77,40 @@ public void call(String resp) {
77
77
78
78
protected static void executeStreamingViaObservableHttpWithForEach (final HttpAsyncClient client ) throws URISyntaxException , IOException , InterruptedException {
79
79
System .out .println ("---- executeStreamingViaObservableHttpWithForEach" );
80
- for (int i = 0 ; i < 5 ; i ++) {
81
- final int c = i + 1 ;
82
- ObservableHttp .createRequest (HttpAsyncMethods .createGet ("http://ec2-54-211-91-164.compute-1.amazonaws.com:8077/eventbus.stream?topic=hystrix-metrics" ), client )
83
- .toObservable ()
84
- .flatMap (new Func1 <ObservableHttpResponse , Observable <String >>() {
85
-
86
- @ Override
87
- public Observable <String > call (ObservableHttpResponse response ) {
88
- return response .getContent ().map (new Func1 <byte [], String >() {
89
-
90
- @ Override
91
- public String call (byte [] bb ) {
92
- return new String (bb );
93
- }
94
-
95
- });
96
- }
97
- })
98
- .filter (new Func1 <String , Boolean >() {
99
-
100
- @ Override
101
- public Boolean call (String t1 ) {
102
- return !t1 .startsWith (": ping" );
103
- }
104
- })
105
- .take (3 )
106
- .toBlockingObservable ()
107
- .forEach (new Action1 <String >() {
108
-
109
- @ Override
110
- public void call (String resp ) {
111
- System .out .println ("Response [" + c + "]: " + resp + " (" + resp .length () + ")" );
112
- }
113
- });
114
- }
80
+ // URL against https://github.com/Netflix/Hystrix/tree/master/hystrix-examples-webapp
81
+ // More information at https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-metrics-event-stream
82
+ ObservableHttp .createRequest (HttpAsyncMethods .createGet ("http://localhost:8989/hystrix-examples-webapp/hystrix.stream" ), client )
83
+ .toObservable ()
84
+ .flatMap (new Func1 <ObservableHttpResponse , Observable <String >>() {
85
+
86
+ @ Override
87
+ public Observable <String > call (ObservableHttpResponse response ) {
88
+ return response .getContent ().map (new Func1 <byte [], String >() {
89
+
90
+ @ Override
91
+ public String call (byte [] bb ) {
92
+ return new String (bb );
93
+ }
94
+
95
+ });
96
+ }
97
+ })
98
+ .filter (new Func1 <String , Boolean >() {
99
+
100
+ @ Override
101
+ public Boolean call (String t1 ) {
102
+ return !t1 .startsWith (": ping" );
103
+ }
104
+ })
105
+ .take (3 )
106
+ .toBlockingObservable ()
107
+ .forEach (new Action1 <String >() {
108
+
109
+ @ Override
110
+ public void call (String resp ) {
111
+ System .out .println (resp );
112
+ }
113
+ });
115
114
}
116
115
117
116
}
0 commit comments