30
30
import org .springframework .scheduling .annotation .Async ;
31
31
import org .springframework .scheduling .annotation .Scheduled ;
32
32
import org .springframework .stereotype .Component ;
33
- import org .springframework .web .reactive .function .client .WebClient ;
34
33
34
+ import ch .xxx .trader .domain .common .WebUtils ;
35
35
import ch .xxx .trader .domain .model .dto .WrapperCb ;
36
36
import ch .xxx .trader .domain .model .entity .QuoteBf ;
37
37
import ch .xxx .trader .domain .model .entity .QuoteBs ;
@@ -59,7 +59,6 @@ public class ScheduledTask {
59
59
private static final String URLPA = "https://api.paxos.com/v2" ;
60
60
private static final String URLBF = "https://api.bitfinex.com" ;
61
61
62
- private final WebClient webClient ;
63
62
private final BitstampService bitstampService ;
64
63
private final BitfinexService bitfinexService ;
65
64
private final ItbitService itbitService ;
@@ -69,9 +68,7 @@ public class ScheduledTask {
69
68
private final Scheduler mongoImportScheduler = Schedulers .newBoundedElastic (20 , 40 , "mongoImport" , 10 );
70
69
71
70
public ScheduledTask (BitstampService bitstampService , MyUserService myUserService , EventMapper messageMapper ,
72
- BitfinexService bitfinexService , ItbitService itbitService , CoinbaseService coinbaseService ,
73
- WebClient webClient ) {
74
- this .webClient = webClient ;
71
+ BitfinexService bitfinexService , ItbitService itbitService , CoinbaseService coinbaseService ) {
75
72
this .bitstampService = bitstampService ;
76
73
this .bitfinexService = bitfinexService ;
77
74
this .itbitService = itbitService ;
@@ -106,7 +103,7 @@ private void insertBsQuote(String currPair) {
106
103
final AtomicBoolean exceptionLogged = new AtomicBoolean (false );
107
104
Disposable subscribe = null ;
108
105
try {
109
- Mono <QuoteBs > request = this . webClient .get ()
106
+ Mono <QuoteBs > request = WebUtils . createWebClient () .get ()
110
107
.uri (String .format ("%s/v2/ticker/%s/" , ScheduledTask .URLBS , currPair ))
111
108
.accept (MediaType .APPLICATION_JSON ).exchangeToMono (response -> response .bodyToMono (QuoteBs .class ))
112
109
.map (res -> {
@@ -178,7 +175,7 @@ public void insertCoinbaseQuote() {
178
175
final AtomicBoolean exceptionLogged = new AtomicBoolean (false );
179
176
Disposable subscribe = null ;
180
177
try {
181
- Mono <QuoteCb > request = this . webClient .get ().uri (ScheduledTask .URLCB + "/exchange-rates?currency=BTC" )
178
+ Mono <QuoteCb > request = WebUtils . createWebClient () .get ().uri (ScheduledTask .URLCB + "/exchange-rates?currency=BTC" )
182
179
.accept (MediaType .APPLICATION_JSON ).exchangeToMono (response -> {
183
180
return response .bodyToMono (WrapperCb .class );
184
181
// return response.bodyToMono(String.class);
@@ -217,7 +214,7 @@ public void insertItbitUsdQuote() {
217
214
final AtomicBoolean exceptionLogged = new AtomicBoolean (false );
218
215
Disposable subscribe = null ;
219
216
try {
220
- Mono <QuoteIb > request = this . webClient .get ()
217
+ Mono <QuoteIb > request = WebUtils . createWebClient () .get ()
221
218
.uri (String .format ("%s/markets/%s/ticker" , ScheduledTask .URLPA , currPair ))
222
219
.accept (MediaType .APPLICATION_JSON )
223
220
.exchangeToMono (response -> response .bodyToMono (PaxosQuote .class )).map (res -> {
@@ -309,7 +306,7 @@ private void insertBfQuote(String currPair) {
309
306
final AtomicBoolean exceptionLogged = new AtomicBoolean (false );
310
307
Disposable subscribe = null ;
311
308
try {
312
- Mono <QuoteBf > request = this . webClient .get ()
309
+ Mono <QuoteBf > request = WebUtils . createWebClient () .get ()
313
310
.uri (String .format ("%s/v1/pubticker/%s" , ScheduledTask .URLBF , currPair ))
314
311
.accept (MediaType .APPLICATION_JSON ).exchangeToMono (response -> response .bodyToMono (QuoteBf .class ))
315
312
.map (res -> {
0 commit comments