Interface Client
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
ClientInstance
public interface Client extends AutoCloseable
The Container that hosts AMQP Connections. From this container new connections can be created and an API exists to close all open connections hosted in this container instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes all currently openConnection
instances created by this client.Future<Client>
closeAsync()
Closes all currently openConnection
instances created by this client.Connection
connect(String host)
Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.Connection
connect(String host, int port)
Connect to the specified host and port, without credentials and with all connection options set to their defaults.Connection
connect(String host, int port, ConnectionOptions options)
Connect to the specified host and port, with given connection options.Connection
connect(String host, ConnectionOptions options)
Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.String
containerId()
static Client
create()
static Client
create(ClientOptions options)
Create a newClient
instance using provided configuration options.
-
-
-
Method Detail
-
create
static Client create(ClientOptions options)
Create a newClient
instance using provided configuration options.- Parameters:
options
- The configuration options to use when creating the client.- Returns:
- a new
Client
instance configured using the provided options.
-
close
void close()
Closes all currently openConnection
instances created by this client.This method blocks and waits for each connection to close in turn using the configured close timeout of the
ConnectionOptions
that the connection was created with.- Specified by:
close
in interfaceAutoCloseable
-
closeAsync
Future<Client> closeAsync()
Closes all currently openConnection
instances created by this client.This method does not block and wait for each connection to be closed in turn, instead it returns a future which will be completed once the close of all connections has been completed.
- Returns:
- a
Future
that will be completed when all open connections have closed.
-
connect
Connection connect(String host, int port) throws ClientException
Connect to the specified host and port, without credentials and with all connection options set to their defaults.The connection returned may still fail afterwards as the majority of connection setup is done asynchronously so the application should be prepared for errors to arise of the connection methods if the open future is not waited on.
- Parameters:
host
- the host to connect toport
- the port to connect to- Returns:
- connection, establishment not yet completed
- Throws:
ClientException
- if theClient
is closed or an error occurs during connect.
-
connect
Connection connect(String host, int port, ConnectionOptions options) throws ClientException
Connect to the specified host and port, with given connection options.The connection returned may still fail afterwards as the majority of connection setup is done asynchronously so the application should be prepared for errors to arise of the connection methods if the open future is not waited on.
- Parameters:
host
- the host to connect toport
- the port to connect tooptions
- options to use when creating the connection.- Returns:
- connection, establishment not yet completed
- Throws:
ClientException
- if theClient
is closed or an error occurs during connect.
-
connect
Connection connect(String host) throws ClientException
Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.The connection returned may still fail afterwards as the majority of connection setup is done asynchronously so the application should be prepared for errors to arise of the connection methods if the open future is not waited on.
- Parameters:
host
- the host to connect to- Returns:
- connection, establishment not yet completed
- Throws:
ClientException
- if theClient
is closed or an error occurs during connect.
-
connect
Connection connect(String host, ConnectionOptions options) throws ClientException
Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.The connection returned may still fail afterwards as the majority of connection setup is done asynchronously so the application should be prepared for errors to arise of the connection methods if the open future is not waited on.
- Parameters:
host
- the host to connect tooptions
- options to use when creating the connection.- Returns:
- connection, establishment not yet completed
- Throws:
ClientException
- if theClient
is closed or an error occurs during connect.
-
-