public class HttpRequestDuplicator extends AbstractStreamMessageDuplicator<HttpObject,HttpRequest>
HttpRequest multiple times by duplicating the stream.
final HttpRequest originalReq = ...
final HttpRequestDuplicator reqDuplicator = new HttpRequestDuplicator(originalReq);
final HttpRequest dupReq1 = reqDuplicator.duplicateStream();
final HttpRequest dupReq2 = reqDuplicator.duplicateStream(true); // the last stream
dupReq1.subscribe(new FooSubscriber() {
...
// Do something according to the first few elements of the request.
});
final CompletableFuture<AggregatedHttpRequest> future2 = dupReq2.aggregate();
future2.handle((message, cause) -> {
// Do something with message.
}
| Constructor and Description |
|---|
HttpRequestDuplicator(HttpRequest req)
Creates a new instance wrapping an
HttpRequest and publishing to multiple subscribers. |
HttpRequestDuplicator(HttpRequest req,
long maxSignalLength)
Creates a new instance wrapping an
HttpRequest and publishing to multiple subscribers. |
HttpRequestDuplicator(HttpRequest req,
long maxSignalLength,
io.netty.util.concurrent.EventExecutor executor)
Creates a new instance wrapping an
HttpRequest and publishing to multiple subscribers. |
| Modifier and Type | Method and Description |
|---|---|
HttpRequest |
duplicateStream()
Creates a new
StreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator. |
HttpRequest |
duplicateStream(boolean lastStream)
Creates a new
StreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator. |
HttpRequest |
duplicateStream(RequestHeaders newHeaders)
Creates a new
HttpRequest instance that publishes data from the publisher you create
this factory with. |
HttpRequest |
duplicateStream(RequestHeaders newHeaders,
boolean lastStream)
Creates a new
HttpRequest instance that publishes data from the publisher you create
this factory with. |
abort, abort, close, duplicatorExecutorpublic HttpRequestDuplicator(HttpRequest req)
HttpRequest and publishing to multiple subscribers.
The length of request is limited by default with the server-side parameter which is
Flags.defaultMaxResponseLength(). If you are at client-side, you need to use
HttpRequestDuplicator(HttpRequest, long) and the long value should be greater than
the length of request or 0 which disables the limit.req - the request that will publish data to subscriberspublic HttpRequestDuplicator(HttpRequest req, long maxSignalLength)
HttpRequest and publishing to multiple subscribers.req - the request that will publish data to subscribersmaxSignalLength - the maximum length of signals. 0 disables the length limitpublic HttpRequestDuplicator(HttpRequest req, long maxSignalLength, @Nullable io.netty.util.concurrent.EventExecutor executor)
HttpRequest and publishing to multiple subscribers.req - the request that will publish data to subscribersmaxSignalLength - the maximum length of signals. 0 disables the length limitexecutor - the executor to use for upstream signals.public HttpRequest duplicateStream()
AbstractStreamMessageDuplicatorStreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator.duplicateStream in class AbstractStreamMessageDuplicator<HttpObject,HttpRequest>public HttpRequest duplicateStream(boolean lastStream)
AbstractStreamMessageDuplicatorStreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator.duplicateStream in class AbstractStreamMessageDuplicator<HttpObject,HttpRequest>lastStream - whether to prevent further duplicationpublic HttpRequest duplicateStream(RequestHeaders newHeaders)
HttpRequest instance that publishes data from the publisher you create
this factory with.public HttpRequest duplicateStream(RequestHeaders newHeaders, boolean lastStream)
HttpRequest instance that publishes data from the publisher you create
this factory with. If you specify the lastStream as true, it will prevent further
creation of duplicate stream.Copyright © 2020 LeanCloud. All rights reserved.