Fix subscription thread
This commit is contained in:
parent
f5e8eecf7c
commit
0351da737e
|
@ -99,7 +99,7 @@ public class EventBusFlux {
|
||||||
var responseHandler = MonoUtils.toHandler(itemSink);
|
var responseHandler = MonoUtils.toHandler(itemSink);
|
||||||
eventBus.request(subscriptionAddress + ".signal", SignalMessage.<T>onNext(item), signalDeliveryOptions, responseHandler);
|
eventBus.request(subscriptionAddress + ".signal", SignalMessage.<T>onNext(item), signalDeliveryOptions, responseHandler);
|
||||||
}))
|
}))
|
||||||
.publishOn(Schedulers.parallel())
|
.subscribeOn(Schedulers.parallel())
|
||||||
.subscribe(response -> {}, error -> {
|
.subscribe(response -> {}, error -> {
|
||||||
if (error instanceof ReplyException) {
|
if (error instanceof ReplyException) {
|
||||||
var errorMessageCode = ((ReplyException) error).failureCode();
|
var errorMessageCode = ((ReplyException) error).failureCode();
|
||||||
|
@ -313,7 +313,7 @@ public class EventBusFlux {
|
||||||
})))
|
})))
|
||||||
.publishOn(Schedulers.boundedElastic())
|
.publishOn(Schedulers.boundedElastic())
|
||||||
.onBackpressureBuffer()
|
.onBackpressureBuffer()
|
||||||
.publishOn(Schedulers.parallel())
|
.subscribeOn(Schedulers.parallel())
|
||||||
.subscribe(v -> {}, emitter::error);
|
.subscribe(v -> {}, emitter::error);
|
||||||
|
|
||||||
emitter.onDispose(() -> {
|
emitter.onDispose(() -> {
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class TDLibRemoteClient implements AutoCloseable {
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.publishOn(Schedulers.parallel())
|
.subscribeOn(Schedulers.parallel())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
v -> {},
|
v -> {},
|
||||||
ex -> logger.error("Bots starter activity crashed. From now on, no new bots can be started anymore", ex)
|
ex -> logger.error("Bots starter activity crashed. From now on, no new bots can be started anymore", ex)
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class AsyncTdDirectImpl implements AsyncTdDirect {
|
||||||
result -> logger.warn("Close result: {}", result),
|
result -> logger.warn("Close result: {}", result),
|
||||||
ex -> logger.error("Error when disposing td client", ex)
|
ex -> logger.error("Error when disposing td client", ex)
|
||||||
);
|
);
|
||||||
}).publishOn(Schedulers.parallel()).subscribe();
|
}).subscribeOn(Schedulers.parallel()).subscribe();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.boundedElastic())
|
.subscribeOn(Schedulers.boundedElastic())
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class TestClient implements TelegramClient {
|
||||||
.asFlux()
|
.asFlux()
|
||||||
.buffer(50)
|
.buffer(50)
|
||||||
.doOnNext(ub -> logger.trace("Received update block of size {}", ub.size()))
|
.doOnNext(ub -> logger.trace("Received update block of size {}", ub.size()))
|
||||||
.publishOn(testClientScheduler)
|
.subscribeOn(testClientScheduler)
|
||||||
.subscribe(updatesHandler::onUpdates, updateExceptionHandler::onException);
|
.subscribe(updatesHandler::onUpdates, updateExceptionHandler::onException);
|
||||||
|
|
||||||
for (String featureName : features) {
|
for (String featureName : features) {
|
||||||
|
@ -70,7 +70,7 @@ public class TestClient implements TelegramClient {
|
||||||
.repeat()
|
.repeat()
|
||||||
.buffer(100)
|
.buffer(100)
|
||||||
.doOnNext(updatesHandler::onUpdates)
|
.doOnNext(updatesHandler::onUpdates)
|
||||||
.publishOn(testClientScheduler)
|
.subscribeOn(testClientScheduler)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class AsyncTdEasy {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.doOnComplete(() -> {
|
.doOnComplete(() -> {
|
||||||
authState.asFlux().take(1).single().publishOn(scheduler).subscribe(authState -> {
|
authState.asFlux().take(1).single().subscribeOn(scheduler).subscribe(authState -> {
|
||||||
onUpdatesTerminated();
|
onUpdatesTerminated();
|
||||||
if (authState.getConstructor() != AuthorizationStateClosed.CONSTRUCTOR) {
|
if (authState.getConstructor() != AuthorizationStateClosed.CONSTRUCTOR) {
|
||||||
logger.warn("Updates stream has closed while"
|
logger.warn("Updates stream has closed while"
|
||||||
|
@ -105,7 +105,7 @@ public class AsyncTdEasy {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).doOnError(ex -> {
|
}).doOnError(ex -> {
|
||||||
authState.asFlux().take(1).single().publishOn(scheduler).subscribe(authState -> {
|
authState.asFlux().take(1).single().subscribeOn(scheduler).subscribe(authState -> {
|
||||||
onUpdatesTerminated();
|
onUpdatesTerminated();
|
||||||
if (authState.getConstructor() != AuthorizationStateClosed.CONSTRUCTOR) {
|
if (authState.getConstructor() != AuthorizationStateClosed.CONSTRUCTOR) {
|
||||||
logger.warn("Updates stream has terminated with an error while"
|
logger.warn("Updates stream has terminated with an error while"
|
||||||
|
@ -136,7 +136,7 @@ public class AsyncTdEasy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register fatal error handler
|
// Register fatal error handler
|
||||||
fatalError.asMono().flatMap(settings.getFatalErrorHandler()::onFatalError).publishOn(scheduler).subscribe();
|
fatalError.asMono().flatMap(settings.getFatalErrorHandler()::onFatalError).subscribeOn(scheduler).subscribe();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class AsyncTdMiddleEventBusServer extends AbstractVerticle {
|
||||||
}
|
}
|
||||||
}).subscribeOn(Schedulers.boundedElastic()))
|
}).subscribeOn(Schedulers.boundedElastic()))
|
||||||
.then()
|
.then()
|
||||||
.publishOn(Schedulers.parallel())
|
.subscribeOn(Schedulers.parallel())
|
||||||
.subscribe(v -> {},
|
.subscribe(v -> {},
|
||||||
ex -> logger.error("Error when processing an execute request", ex),
|
ex -> logger.error("Error when processing an execute request", ex),
|
||||||
() -> logger.trace("Finished handling execute requests")
|
() -> logger.trace("Finished handling execute requests")
|
||||||
|
@ -182,7 +182,7 @@ public class AsyncTdMiddleEventBusServer extends AbstractVerticle {
|
||||||
}
|
}
|
||||||
BinlogUtils
|
BinlogUtils
|
||||||
.readBinlogConsumer(vertx, readBinlogConsumer, botId, local)
|
.readBinlogConsumer(vertx, readBinlogConsumer, botId, local)
|
||||||
.publishOn(Schedulers.parallel())
|
.subscribeOn(Schedulers.parallel())
|
||||||
.subscribe(v -> {}, ex -> logger.error("Error when processing a read-binlog request", ex));
|
.subscribe(v -> {}, ex -> logger.error("Error when processing a read-binlog request", ex));
|
||||||
|
|
||||||
MessageConsumer<byte[]> readyToReceiveConsumer = vertx.eventBus().consumer(botAddress + ".ready-to-receive");
|
MessageConsumer<byte[]> readyToReceiveConsumer = vertx.eventBus().consumer(botAddress + ".ready-to-receive");
|
||||||
|
@ -255,7 +255,7 @@ public class AsyncTdMiddleEventBusServer extends AbstractVerticle {
|
||||||
.andThen(pingConsumer.rxCompletionHandler())
|
.andThen(pingConsumer.rxCompletionHandler())
|
||||||
.as(MonoUtils::toMono)
|
.as(MonoUtils::toMono)
|
||||||
.doOnSuccess(s -> logger.trace("Finished preparing listeners"))
|
.doOnSuccess(s -> logger.trace("Finished preparing listeners"))
|
||||||
.publishOn(Schedulers.parallel())
|
.subscribeOn(Schedulers.parallel())
|
||||||
.subscribe(v -> {}, registrationSink::error, registrationSink::success);
|
.subscribe(v -> {}, registrationSink::error, registrationSink::success);
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.boundedElastic())
|
.subscribeOn(Schedulers.boundedElastic())
|
||||||
|
|
|
@ -343,7 +343,7 @@ public class MonoUtils {
|
||||||
|
|
||||||
private static Future<Void> toVertxFuture(Mono<Void> toTransform) {
|
private static Future<Void> toVertxFuture(Mono<Void> toTransform) {
|
||||||
var promise = Promise.<Void>promise();
|
var promise = Promise.<Void>promise();
|
||||||
toTransform.publishOn(Schedulers.parallel()).subscribe(next -> {}, promise::fail, promise::complete);
|
toTransform.subscribeOn(Schedulers.parallel()).subscribe(next -> {}, promise::fail, promise::complete);
|
||||||
return promise.future();
|
return promise.future();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ public class MonoUtils {
|
||||||
if (backpressureSize != null) {
|
if (backpressureSize != null) {
|
||||||
AtomicBoolean drained = new AtomicBoolean(true);
|
AtomicBoolean drained = new AtomicBoolean(true);
|
||||||
var drainSubscription = backpressureSize
|
var drainSubscription = backpressureSize
|
||||||
.publishOn(Schedulers.boundedElastic())
|
.subscribeOn(Schedulers.boundedElastic())
|
||||||
.subscribe(size -> {
|
.subscribe(size -> {
|
||||||
writeQueueFull = size >= this.writeQueueMaxSize;
|
writeQueueFull = size >= this.writeQueueMaxSize;
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ public class MonoUtils {
|
||||||
termination
|
termination
|
||||||
.asMono()
|
.asMono()
|
||||||
.doOnTerminate(drainSubscription::dispose)
|
.doOnTerminate(drainSubscription::dispose)
|
||||||
.publishOn(Schedulers.boundedElastic())
|
.subscribeOn(Schedulers.boundedElastic())
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ public class MonoUtils {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public io.vertx.core.streams.ReadStream<T> handler(@io.vertx.codegen.annotations.Nullable Handler<T> handler) {
|
public io.vertx.core.streams.ReadStream<T> handler(@io.vertx.codegen.annotations.Nullable Handler<T> handler) {
|
||||||
sink.asFlux().publishOn(scheduler).subscribe(new CoreSubscriber<T>() {
|
sink.asFlux().subscribeOn(scheduler).subscribe(new CoreSubscriber<T>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NotNull Subscription s) {
|
public void onSubscribe(@NotNull Subscription s) {
|
||||||
|
@ -656,7 +656,7 @@ public class MonoUtils {
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
@Override
|
@Override
|
||||||
public io.vertx.core.streams.ReadStream<T> handler(@io.vertx.codegen.annotations.Nullable Handler<T> handler) {
|
public io.vertx.core.streams.ReadStream<T> handler(@io.vertx.codegen.annotations.Nullable Handler<T> handler) {
|
||||||
flux.publishOn(scheduler).subscribe(new CoreSubscriber<T>() {
|
flux.subscribeOn(scheduler).subscribe(new CoreSubscriber<T>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NotNull Subscription s) {
|
public void onSubscribe(@NotNull Subscription s) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user