Class ClientInstance
- java.lang.Object
-
- org.apache.qpid.protonj2.client.impl.ClientInstance
-
- All Implemented Interfaces:
AutoCloseable,Client
public final class ClientInstance extends Object implements Client
Container ofConnectioninstances that are all created with the same container parent and therefore share the same container Id.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes all currently openConnectioninstances created by this client.Future<Client>closeAsync()Closes all currently openConnectioninstances created by this client.Connectionconnect(String host)Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.Connectionconnect(String host, int port)Connect to the specified host and port, without credentials and with all connection options set to their defaults.Connectionconnect(String host, int port, ConnectionOptions options)Connect to the specified host and port, with given connection options.Connectionconnect(String host, ConnectionOptions options)Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.StringcontainerId()static ClientInstancecreate()static ClientInstancecreate(ClientOptions options)Create a newClientinstance using provided configuration options.
-
-
-
Method Detail
-
create
public static ClientInstance create()
- Returns:
- a newly create
ClientInstancethat uses default configuration.
-
create
public static ClientInstance create(ClientOptions options)
Description copied from interface:ClientCreate a newClientinstance using provided configuration options.- Parameters:
options- The configuration options to apply to the newly createClientInstance.- Returns:
- a newly create
ClientInstancethat uses the configuration provided.
-
connect
public Connection connect(String host, int port) throws ClientException
Description copied from interface:ClientConnect 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.
- Specified by:
connectin interfaceClient- Parameters:
host- the host to connect toport- the port to connect to- Returns:
- connection, establishment not yet completed
- Throws:
ClientException- if theClientis closed or an error occurs during connect.
-
connect
public Connection connect(String host, int port, ConnectionOptions options) throws ClientException
Description copied from interface:ClientConnect 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.
- Specified by:
connectin interfaceClient- 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 theClientis closed or an error occurs during connect.
-
connect
public Connection connect(String host) throws ClientException
Description copied from interface:ClientConnect 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.
- Specified by:
connectin interfaceClient- Parameters:
host- the host to connect to- Returns:
- connection, establishment not yet completed
- Throws:
ClientException- if theClientis closed or an error occurs during connect.
-
connect
public Connection connect(String host, ConnectionOptions options) throws ClientException
Description copied from interface:ClientConnect 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.
- Specified by:
connectin interfaceClient- Parameters:
host- the host to connect tooptions- options to use when creating the connection.- Returns:
- connection, establishment not yet completed
- Throws:
ClientException- if theClientis closed or an error occurs during connect.
-
containerId
public String containerId()
- Specified by:
containerIdin interfaceClient- Returns:
- the container id assigned to this
Clientinstance.
-
close
public void close()
Description copied from interface:ClientCloses all currently openConnectioninstances created by this client.This method blocks and waits for each connection to close in turn using the configured close timeout of the
ConnectionOptionsthat the connection was created with.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceClient
-
closeAsync
public Future<Client> closeAsync()
Description copied from interface:ClientCloses all currently openConnectioninstances 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.
- Specified by:
closeAsyncin interfaceClient- Returns:
- a
Futurethat will be completed when all open connections have closed.
-
-