Class Http
- All Implemented Interfaces:
org.apache.pekko.actor.Extension
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic T
apply
(org.apache.pekko.actor.ActorSystem system) static T
apply
(org.apache.pekko.actor.ClassicActorSystemProvider system) <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> Returns apekko.stream.javadsl.Flow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> Returns apekko.stream.javadsl.Flow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> cachedHostConnectionPool
(ConnectHttp to, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Returns apekko.stream.javadsl.Flow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> Same as<T>cachedHostConnectionPool(java.lang.String)
but with HTTPS encryption.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> cachedHostConnectionPoolHttps
(ConnectHttp to, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Same as<T>cachedHostConnectionPool(java.lang.String)
but with HTTPS encryption.org.apache.pekko.stream.javadsl.BidiFlow<HttpRequest,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpResponse, org.apache.pekko.NotUsed> clientLayer
(Host hostHeader) Constructs a client layer stage using the configured defaultpekko.http.javadsl.settings.ClientConnectionSettings
.org.apache.pekko.stream.javadsl.BidiFlow<HttpRequest,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpResponse, org.apache.pekko.NotUsed> clientLayer
(Host hostHeader, ClientConnectionSettings settings) Constructs a client layer stage using the givenpekko.http.javadsl.settings.ClientConnectionSettings
.org.apache.pekko.stream.javadsl.BidiFlow<HttpRequest,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpResponse, org.apache.pekko.NotUsed> clientLayer
(Host hostHeader, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Constructs a client layer stage using the givenClientConnectionSettings
.connectionTo
(String host) Creates a builder which will create a single connection to a host every time the built flow is materialized.static Http
createExtension
(org.apache.pekko.actor.ExtendedActorSystem system) Gets the current default client-sideConnectionContext
.static final boolean
static Http
get
(org.apache.pekko.actor.ActorSystem system) static Http
get
(org.apache.pekko.actor.ClassicActorSystemProvider system) static final int
hashCode()
static Http$
lookup()
<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> newHostConnectionPool
(String host, org.apache.pekko.stream.Materializer materializer) Starts a new connection pool to the given host and configuration and returns apekko.stream.javadsl.Flow
which dispatches the requests from all its materializations across this pool.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> newHostConnectionPool
(ConnectHttp to, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log, org.apache.pekko.stream.Materializer materializer) Same as<T>newHostConnectionPool(java.lang.String,org.apache.pekko.stream.Materializer)
but with HTTPS encryption.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> newHostConnectionPool
(ConnectHttp to, org.apache.pekko.stream.Materializer materializer) Starts a new connection pool to the given host and configuration and returns apekko.stream.javadsl.Flow
which dispatches the requests from all its materializations across this pool.newServerAt
(String interface_, int port) Main entry point to create a server binding.org.apache.pekko.stream.javadsl.Flow<HttpRequest,
HttpResponse, CompletionStage<OutgoingConnection>> outgoingConnection
(String host) Creates apekko.stream.javadsl.Flow
representing a prospective HTTP client connection to the given endpoint.org.apache.pekko.stream.javadsl.Flow<HttpRequest,
HttpResponse, CompletionStage<OutgoingConnection>> Creates apekko.stream.javadsl.Flow
representing a prospective HTTP client connection to the given endpoint.org.apache.pekko.stream.javadsl.Flow<HttpRequest,
HttpResponse, CompletionStage<OutgoingConnection>> outgoingConnection
(ConnectHttp to, Optional<InetSocketAddress> localAddress, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Creates apekko.stream.javadsl.Flow
representing a prospective HTTP client connection to the given endpoint.org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> Constructs a server layer stage using the configured defaultpekko.http.javadsl.settings.ServerSettings
.org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> serverLayer
(ServerSettings settings) Constructs a server layer stage using the givenpekko.http.javadsl.settings.ServerSettings
.org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> serverLayer
(ServerSettings settings, Optional<InetSocketAddress> remoteAddress) Constructs a server layer stage using the givenpekko.http.javadsl.settings.ServerSettings
.org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> serverLayer
(ServerSettings settings, Optional<InetSocketAddress> remoteAddress, org.apache.pekko.event.LoggingAdapter log) Constructs a server layer stage using the givenServerSettings
.void
Sets the default client-sideConnectionContext
.CompletionStage<scala.runtime.BoxedUnit>
Triggers an orderly shutdown of all host connections pools currently maintained by thepekko.actor.ActorSystem
.singleRequest
(HttpRequest request) Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.singleRequest
(HttpRequest request, HttpsConnectionContext connectionContext) Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.singleRequest
(HttpRequest request, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.<T> org.apache.pekko.japi.Pair<CompletionStage<WebSocketUpgradeResponse>,
T> singleWebSocketRequest
(WebSocketRequest request, org.apache.pekko.stream.javadsl.Flow<Message, Message, T> clientFlow, ConnectionContext connectionContext, Optional<InetSocketAddress> localAddress, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log, org.apache.pekko.stream.Materializer materializer) Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.<T> org.apache.pekko.japi.Pair<CompletionStage<WebSocketUpgradeResponse>,
T> singleWebSocketRequest
(WebSocketRequest request, org.apache.pekko.stream.javadsl.Flow<Message, Message, T> clientFlow, ConnectionContext connectionContext, org.apache.pekko.stream.Materializer materializer) Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.<T> org.apache.pekko.japi.Pair<CompletionStage<WebSocketUpgradeResponse>,
T> singleWebSocketRequest
(WebSocketRequest request, org.apache.pekko.stream.javadsl.Flow<Message, Message, T> clientFlow, org.apache.pekko.stream.Materializer materializer) Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, org.apache.pekko.NotUsed> Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, org.apache.pekko.NotUsed> superPool
(ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs.<T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,
T>, org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, org.apache.pekko.NotUsed> superPool
(ConnectionPoolSettings settings, HttpsConnectionContext connectionContext, org.apache.pekko.event.LoggingAdapter log) Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs.org.apache.pekko.stream.javadsl.Flow<Message,
Message, CompletionStage<WebSocketUpgradeResponse>> webSocketClientFlow
(WebSocketRequest request) Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.org.apache.pekko.stream.javadsl.Flow<Message,
Message, CompletionStage<WebSocketUpgradeResponse>> webSocketClientFlow
(WebSocketRequest request, ConnectionContext connectionContext, Optional<InetSocketAddress> localAddress, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.org.apache.pekko.stream.javadsl.BidiFlow<Message,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, Message, CompletionStage<WebSocketUpgradeResponse>> webSocketClientLayer
(WebSocketRequest request) Constructs a WebSocketpekko.stream.javadsl.BidiFlow
.org.apache.pekko.stream.javadsl.BidiFlow<Message,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, Message, CompletionStage<WebSocketUpgradeResponse>> webSocketClientLayer
(WebSocketRequest request, ClientConnectionSettings settings) Constructs a WebSocketpekko.stream.javadsl.BidiFlow
using the configured defaultClientConnectionSettings
, configured using thepekko.http.client
config section.org.apache.pekko.stream.javadsl.BidiFlow<Message,
org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, org.apache.pekko.stream.TLSProtocol.SslTlsInbound, Message, CompletionStage<WebSocketUpgradeResponse>> webSocketClientLayer
(WebSocketRequest request, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Constructs a WebSocketpekko.stream.javadsl.BidiFlow
using the configured defaultClientConnectionSettings
, configured using thepekko.http.client
config section.
-
Constructor Details
-
Http
public Http(org.apache.pekko.actor.ExtendedActorSystem system)
-
-
Method Details
-
get
-
get
-
lookup
-
createExtension
-
apply
public static T apply(org.apache.pekko.actor.ActorSystem system) -
apply
public static T apply(org.apache.pekko.actor.ClassicActorSystemProvider system) -
hashCode
public static final int hashCode() -
equals
-
serverLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, serverLayer()org.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> Constructs a server layer stage using the configured defaultpekko.http.javadsl.settings.ServerSettings
. The returnedpekko.stream.javadsl.BidiFlow
isn't reusable and can only be materialized once.- Returns:
- (undocumented)
-
serverLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, serverLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> (ServerSettings settings) Constructs a server layer stage using the givenpekko.http.javadsl.settings.ServerSettings
. The returnedpekko.stream.javadsl.BidiFlow
isn't reusable and can only be materialized once.- Parameters:
settings
- (undocumented)- Returns:
- (undocumented)
-
serverLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, serverLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> (ServerSettings settings, Optional<InetSocketAddress> remoteAddress) Constructs a server layer stage using the givenpekko.http.javadsl.settings.ServerSettings
. The returnedpekko.stream.javadsl.BidiFlow
isn't reusable and can only be materialized once.- Parameters:
settings
- (undocumented)remoteAddress
- (undocumented)- Returns:
- (undocumented)
-
serverLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpResponse,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, serverLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpRequest, org.apache.pekko.NotUsed> (ServerSettings settings, Optional<InetSocketAddress> remoteAddress, org.apache.pekko.event.LoggingAdapter log) Constructs a server layer stage using the givenServerSettings
. The returnedpekko.stream.javadsl.BidiFlow
isn't reusable and can only be materialized once.- Parameters:
settings
- (undocumented)remoteAddress
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
newServerAt
Main entry point to create a server binding.- Parameters:
interface
- The interface to bind to.port
- The port to bind to or0
if the port should be automatically assigned.interface_
- (undocumented)- Returns:
- (undocumented)
-
clientLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpRequest,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, clientLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpResponse, org.apache.pekko.NotUsed> (Host hostHeader) Constructs a client layer stage using the configured defaultpekko.http.javadsl.settings.ClientConnectionSettings
.- Parameters:
hostHeader
- (undocumented)- Returns:
- (undocumented)
-
clientLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpRequest,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, clientLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpResponse, org.apache.pekko.NotUsed> (Host hostHeader, ClientConnectionSettings settings) Constructs a client layer stage using the givenpekko.http.javadsl.settings.ClientConnectionSettings
.- Parameters:
hostHeader
- (undocumented)settings
- (undocumented)- Returns:
- (undocumented)
-
clientLayer
public org.apache.pekko.stream.javadsl.BidiFlow<HttpRequest,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, clientLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, HttpResponse, org.apache.pekko.NotUsed> (Host hostHeader, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Constructs a client layer stage using the givenClientConnectionSettings
.- Parameters:
hostHeader
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
outgoingConnection
public org.apache.pekko.stream.javadsl.Flow<HttpRequest,HttpResponse, outgoingConnectionCompletionStage<OutgoingConnection>> (String host) Creates apekko.stream.javadsl.Flow
representing a prospective HTTP client connection to the given endpoint. Every materialization of the produced flow will attempt to establish a new outgoing connection.If the hostname is given with an
https://
prefix, the defaultHttpsConnectionContext
will be used.Prefer
connectionTo(java.lang.String)
over this method.- Parameters:
host
- (undocumented)- Returns:
- (undocumented)
-
outgoingConnection
public org.apache.pekko.stream.javadsl.Flow<HttpRequest,HttpResponse, outgoingConnectionCompletionStage<OutgoingConnection>> (ConnectHttp to) Creates apekko.stream.javadsl.Flow
representing a prospective HTTP client connection to the given endpoint. Every materialization of the produced flow will attempt to establish a new outgoing connection.Use the
ConnectHttp
DSL to configure target host and whether HTTPS should be used.Prefer
connectionTo(java.lang.String)
over this method.- Parameters:
to
- (undocumented)- Returns:
- (undocumented)
-
outgoingConnection
public org.apache.pekko.stream.javadsl.Flow<HttpRequest,HttpResponse, outgoingConnectionCompletionStage<OutgoingConnection>> (ConnectHttp to, Optional<InetSocketAddress> localAddress, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Creates apekko.stream.javadsl.Flow
representing a prospective HTTP client connection to the given endpoint. Every materialization of the produced flow will attempt to establish a new outgoing connection.Prefer
connectionTo(java.lang.String)
over this method.- Parameters:
to
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
connectionTo
Creates a builder which will create a single connection to a host every time the built flow is materialized. There is no pooling and you are yourself responsible for lifecycle management of the connection. For a more convenient Request level API seesingleRequest()
- Parameters:
host
- (undocumented)- Returns:
- A builder to configure more specific setup for the connection and then build a
Flow>Request, Response, CompletionStage>OutgoingConnection>>
.
-
newHostConnectionPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, newHostConnectionPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (String host, org.apache.pekko.stream.Materializer materializer) Starts a new connection pool to the given host and configuration and returns apekko.stream.javadsl.Flow
which dispatches the requests from all its materializations across this pool. While the started host connection pool internally shuts itself down automatically after the configured idle timeout it will spin itself up again if more requests arrive from an existing or a new client flow materialization. The returned flow therefore remains usable for the full lifetime of the application.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.- Parameters:
host
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
newHostConnectionPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, newHostConnectionPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (ConnectHttp to, org.apache.pekko.stream.Materializer materializer) Starts a new connection pool to the given host and configuration and returns apekko.stream.javadsl.Flow
which dispatches the requests from all its materializations across this pool. While the started host connection pool internally shuts itself down automatically after the configured idle timeout it will spin itself up again if more requests arrive from an existing or a new client flow materialization. The returned flow therefore remains usable for the full lifetime of the application.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.- Parameters:
to
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
newHostConnectionPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, newHostConnectionPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (ConnectHttp to, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log, org.apache.pekko.stream.Materializer materializer) Same as<T>newHostConnectionPool(java.lang.String,org.apache.pekko.stream.Materializer)
but with HTTPS encryption.The given
ConnectionContext
will be used for encryption on the connection.- Parameters:
to
- (undocumented)settings
- (undocumented)log
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
cachedHostConnectionPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, cachedHostConnectionPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (String host) Returns apekko.stream.javadsl.Flow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint. For every ActorSystem, target host and pool configuration a separate connection pool is maintained. The HTTP layer transparently manages idle shutdown and restarting of connections pools as configured. The returnedpekko.stream.javadsl.Flow
instances therefore remain valid throughout the lifetime of the application.The internal caching logic guarantees that there will never be more than a single pool running for the given target host endpoint and configuration (in this ActorSystem).
Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.- Parameters:
host
- (undocumented)- Returns:
- (undocumented)
-
cachedHostConnectionPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, cachedHostConnectionPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (ConnectHttp to) Returns apekko.stream.javadsl.Flow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint. For every ActorSystem, target host and pool configuration a separate connection pool is maintained. The HTTP layer transparently manages idle shutdown and restarting of connections pools as configured. The returnedpekko.stream.javadsl.Flow
instances therefore remain valid throughout the lifetime of the application.The internal caching logic guarantees that there will never be more than a single pool running for the given target host endpoint and configuration (in this ActorSystem).
Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.- Parameters:
to
- (undocumented)- Returns:
- (undocumented)
-
cachedHostConnectionPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, cachedHostConnectionPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (ConnectHttp to, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Returns apekko.stream.javadsl.Flow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint. For every ActorSystem, target host and pool configuration a separate connection pool is maintained. The HTTP layer transparently manages idle shutdown and restarting of connections pools as configured. The returnedpekko.stream.javadsl.Flow
instances therefore remain valid throughout the lifetime of the application.The internal caching logic guarantees that there will never be more than a single pool running for the given target host endpoint and configuration (in this ActorSystem).
Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.To configure additional settings for the pool (and requests made using it), use the
pekko.http.host-connection-pool
config section or pass in aConnectionPoolSettings
explicitly.- Parameters:
to
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
cachedHostConnectionPoolHttps
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, cachedHostConnectionPoolHttpsorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (ConnectHttp to, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Same as<T>cachedHostConnectionPool(java.lang.String)
but with HTTPS encryption.When an
HttpConnectionContext
is defined in the givenConnectHttp
it will be used, otherwise the default client-side context will be used.- Parameters:
to
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
cachedHostConnectionPoolHttps
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, cachedHostConnectionPoolHttpsorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, HostConnectionPool> (ConnectHttp to) Same as<T>cachedHostConnectionPool(java.lang.String)
but with HTTPS encryption.When an
HttpConnectionContext
is defined in the givenConnectHttp
it will be used, otherwise the default client-side context will be used.- Parameters:
to
- (undocumented)- Returns:
- (undocumented)
-
superPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, superPool()org.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, org.apache.pekko.NotUsed> Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs. Note that incoming requests must have either an absolute URI or a validHost
header.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests
A
andB
enter the flow in that order the response forB
might be produced before the response forA
. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of typeT
from the application which is emitted together with the corresponding response.- Returns:
- (undocumented)
-
superPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, superPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, org.apache.pekko.NotUsed> (ConnectionPoolSettings settings, HttpsConnectionContext connectionContext, org.apache.pekko.event.LoggingAdapter log) Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs. Note that incoming requests must have either an absolute URI or a validHost
header.The given
HttpsConnectionContext
is used to configure TLS for the connection.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests
A
andB
enter theflow
in that order the response forB
might be produced before the response forA
.In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.- Parameters:
settings
- (undocumented)connectionContext
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
superPool
public <T> org.apache.pekko.stream.javadsl.Flow<org.apache.pekko.japi.Pair<HttpRequest,T>, superPoolorg.apache.pekko.japi.Pair<scala.util.Try<HttpResponse>, T>, org.apache.pekko.NotUsed> (ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs. Note that incoming requests must have either an absolute URI or a validHost
header.The
defaultClientHttpsContext()
is used to configure TLS for the connection.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests
A
andB
enter theflow
in that order the response forB
might be produced before the response forA
.In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.- Parameters:
settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
singleRequest
Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.The
defaultClientHttpsContext()
is used to configure TLS for the connection.Note that the request must have either an absolute URI or a valid
Host
header, otherwise the future will be completed with an error.- Parameters:
request
- (undocumented)- Returns:
- (undocumented)
-
singleRequest
public CompletionStage<HttpResponse> singleRequest(HttpRequest request, HttpsConnectionContext connectionContext) Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.The
defaultClientHttpsContext()
is used to configure TLS for the connection.Note that the request must have either an absolute URI or a valid
Host
header, otherwise the future will be completed with an error.- Parameters:
request
- (undocumented)connectionContext
- (undocumented)- Returns:
- (undocumented)
-
singleRequest
public CompletionStage<HttpResponse> singleRequest(HttpRequest request, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, org.apache.pekko.event.LoggingAdapter log) Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.The given
HttpsConnectionContext
will be used for encryption if the request is sent to an https endpoint.Note that the request must have either an absolute URI or a valid
Host
header, otherwise the future will be completed with an error.- Parameters:
request
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
webSocketClientLayer
public org.apache.pekko.stream.javadsl.BidiFlow<Message,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, webSocketClientLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, Message, CompletionStage<WebSocketUpgradeResponse>> (WebSocketRequest request) Constructs a WebSocketpekko.stream.javadsl.BidiFlow
.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)- Returns:
- (undocumented)
-
webSocketClientLayer
public org.apache.pekko.stream.javadsl.BidiFlow<Message,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, webSocketClientLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, Message, CompletionStage<WebSocketUpgradeResponse>> (WebSocketRequest request, ClientConnectionSettings settings) Constructs a WebSocketpekko.stream.javadsl.BidiFlow
using the configured defaultClientConnectionSettings
, configured using thepekko.http.client
config section.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)settings
- (undocumented)- Returns:
- (undocumented)
-
webSocketClientLayer
public org.apache.pekko.stream.javadsl.BidiFlow<Message,org.apache.pekko.stream.TLSProtocol.SslTlsOutbound, webSocketClientLayerorg.apache.pekko.stream.TLSProtocol.SslTlsInbound, Message, CompletionStage<WebSocketUpgradeResponse>> (WebSocketRequest request, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Constructs a WebSocketpekko.stream.javadsl.BidiFlow
using the configured defaultClientConnectionSettings
, configured using thepekko.http.client
config section.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
webSocketClientFlow
public org.apache.pekko.stream.javadsl.Flow<Message,Message, webSocketClientFlowCompletionStage<WebSocketUpgradeResponse>> (WebSocketRequest request) Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)- Returns:
- (undocumented)
-
webSocketClientFlow
public org.apache.pekko.stream.javadsl.Flow<Message,Message, webSocketClientFlowCompletionStage<WebSocketUpgradeResponse>> (WebSocketRequest request, ConnectionContext connectionContext, Optional<InetSocketAddress> localAddress, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log) Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)connectionContext
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
singleWebSocketRequest
public <T> org.apache.pekko.japi.Pair<CompletionStage<WebSocketUpgradeResponse>,T> singleWebSocketRequest(WebSocketRequest request, org.apache.pekko.stream.javadsl.Flow<Message, Message, T> clientFlow, org.apache.pekko.stream.Materializer materializer) Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.The
defaultClientHttpsContext()
is used to configure TLS for the connection.- Parameters:
request
- (undocumented)clientFlow
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
singleWebSocketRequest
public <T> org.apache.pekko.japi.Pair<CompletionStage<WebSocketUpgradeResponse>,T> singleWebSocketRequest(WebSocketRequest request, org.apache.pekko.stream.javadsl.Flow<Message, Message, T> clientFlow, ConnectionContext connectionContext, org.apache.pekko.stream.Materializer materializer) Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.The
defaultClientHttpsContext()
is used to configure TLS for the connection.- Parameters:
request
- (undocumented)clientFlow
- (undocumented)connectionContext
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
singleWebSocketRequest
public <T> org.apache.pekko.japi.Pair<CompletionStage<WebSocketUpgradeResponse>,T> singleWebSocketRequest(WebSocketRequest request, org.apache.pekko.stream.javadsl.Flow<Message, Message, T> clientFlow, ConnectionContext connectionContext, Optional<InetSocketAddress> localAddress, ClientConnectionSettings settings, org.apache.pekko.event.LoggingAdapter log, org.apache.pekko.stream.Materializer materializer) Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.- Parameters:
request
- (undocumented)clientFlow
- (undocumented)connectionContext
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
shutdownAllConnectionPools
Triggers an orderly shutdown of all host connections pools currently maintained by thepekko.actor.ActorSystem
. The returned future is completed when all pools that were live at the time of this method call have completed their shutdown process.If existing pool client flows are re-used or new ones materialized concurrently with or after this method call the respective connection pools will be restarted and not contribute to the returned future.
- Returns:
- (undocumented)
-
defaultClientHttpsContext
Gets the current default client-sideConnectionContext
.- Returns:
- (undocumented)
-
setDefaultClientHttpsContext
Sets the default client-sideConnectionContext
.- Parameters:
context
- (undocumented)
-