Interface Transport
- All Known Implementing Classes:
TcpTransport,TcpTransport,WebSocketTransport,WebSocketTransport
public interface Transport
Base class for all QpidJMS Transport instances.
-
Method Summary
Modifier and TypeMethodDescriptionvoidWaits interruptibly for theTransportto connect to the remote that was indicated in theconnect(String, int, TransportListener)call.voidclose()Close the Transport, no additional send operations are accepted.connect(String host, int port, TransportListener listener) Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc.flush()Request a flush of all pending writes to the underlying connection.Gets a buffer allocator that can produceProtonBufferinstance that may be optimized for use with the underlying transport implementation.getHost()intgetPort()Returns a URI that contains some meaningful information about the remote connection such as a scheme that reflects the transport type and the remote host and port that the connection was instructed to connect to.Gets the currently set TransportListener instancebooleanbooleanisSecure()write(ProtonBuffer output) Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.write(ProtonBuffer output, Runnable ioComplete) Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.writeAndFlush(ProtonBuffer output) Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operationswriteAndFlush(ProtonBuffer output, Runnable ioComplete) Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations
-
Method Details
-
connect
Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc. The connection operation itself will be performed as an asynchronous operation with the success or failure being communicated to the event pointTransportListener.transportError(Throwable). If the users wishes to perform a block on connect outcome theawaitConnect()method will wait for and or throw an error based on the connect outcome.- Parameters:
host- The remote host that thisTransportshould attempt to connect to.port- The port on the remote host that thisTransportshould attempt to bind to.listener- TheTransportListenerthat will handleTransportevents.- Returns:
- this
Transportinstance. - Throws:
IOException- if an error occurs while attempting the connect.
-
awaitConnect
Waits interruptibly for theTransportto connect to the remote that was indicated in theconnect(String, int, TransportListener)call.- Throws:
InterruptedException- If the wait mechanism was interrupted while waiting for a successful connect.IOException- If theTransportfailed to connect or was closed before connected.
-
isConnected
boolean isConnected()- Returns:
- true if transport is connected or false if the connection is down.
-
isSecure
boolean isSecure()- Returns:
- true if transport is connected using a secured channel (SSL).
-
close
Close the Transport, no additional send operations are accepted.- Throws:
IOException- if an error occurs while closing the connection.
-
getBufferAllocator
ProtonBufferAllocator getBufferAllocator()Gets a buffer allocator that can produceProtonBufferinstance that may be optimized for use with the underlying transport implementation.- Returns:
- a
ProtonBufferAllocatorthat creates transport friendly buffers.
-
write
Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.- Parameters:
output- The buffer of data that is to be transmitted.- Returns:
- this
Transportinstance. - Throws:
IOException- if an error occurs during the write operation.
-
write
Writes a chunk of data over the Transport connection without performing an explicit flush on the transport. This method allows for a completion callback that is signaled when the actual low level IO operation is completed which could be after this method has returned.- Parameters:
output- The buffer of data that is to be transmitted.ioComplete- ARunnablethat is invoked when the IO operation completes successfully.- Returns:
- this
Transportinstance. - Throws:
IOException- if an error occurs during the write operation.
-
writeAndFlush
Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations- Parameters:
output- The buffer of data that is to be transmitted.- Returns:
- this
Transportinstance. - Throws:
IOException- if an error occurs during the write operation.
-
writeAndFlush
Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations- Parameters:
output- The buffer of data that is to be transmitted.ioComplete- ARunnablethat is invoked when the IO operation completes successfully.- Returns:
- this
Transportinstance. - Throws:
IOException- if an error occurs during the write operation.
-
flush
Request a flush of all pending writes to the underlying connection.- Returns:
- this
Transportinstance. - Throws:
IOException- if an error occurs during the flush operation.
-
getTransportListener
TransportListener getTransportListener()Gets the currently set TransportListener instance- Returns:
- the current TransportListener or null if none set.
-
getTransportOptions
TransportOptions getTransportOptions()- Returns:
- a
TransportOptionsinstance copied from the immutable options given at create time..
-
getSslOptions
SslOptions getSslOptions()- Returns:
- a
SslOptionsinstance copied from the immutable options given at create time..
-
getHost
String getHost()- Returns:
- the host name or IP address that the transport connects to.
-
getPort
int getPort()- Returns:
- the port that the transport connects to.
-
getRemoteURI
URI getRemoteURI()Returns a URI that contains some meaningful information about the remote connection such as a scheme that reflects the transport type and the remote host and port that the connection was instructed to connect to. If called before theconnect(String, int, TransportListener)method this method returnsnull.- Returns:
- a URI that reflects a meaningful view of the
Transportremote connection details.
-
getLocalPrincipal
Principal getLocalPrincipal()- Returns:
- the local principal for a Transport that is using a secure connection.
-