Interface Transport
- All Known Implementing Classes:
TcpTransport
,TcpTransport
,WebSocketTransport
,WebSocketTransport
public interface Transport
Base class for all QpidJMS Transport instances.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Waits interruptibly for theTransport
to connect to the remote that was indicated in theconnect(String, int, TransportListener)
call.void
close()
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 produceProtonBuffer
instance that may be optimized for use with the underlying transport implementation.getHost()
int
getPort()
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 instanceboolean
boolean
isSecure()
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 thisTransport
should attempt to connect to.port
- The port on the remote host that thisTransport
should attempt to bind to.listener
- TheTransportListener
that will handleTransport
events.- Returns:
- this
Transport
instance. - Throws:
IOException
- if an error occurs while attempting the connect.
-
awaitConnect
Waits interruptibly for theTransport
to 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 theTransport
failed 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 produceProtonBuffer
instance that may be optimized for use with the underlying transport implementation.- Returns:
- a
ProtonBufferAllocator
that 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
Transport
instance. - 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
- ARunnable
that is invoked when the IO operation completes successfully.- Returns:
- this
Transport
instance. - 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
Transport
instance. - 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
- ARunnable
that is invoked when the IO operation completes successfully.- Returns:
- this
Transport
instance. - Throws:
IOException
- if an error occurs during the write operation.
-
flush
Request a flush of all pending writes to the underlying connection.- Returns:
- this
Transport
instance. - 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
TransportOptions
instance copied from the immutable options given at create time..
-
getSslOptions
SslOptions getSslOptions()- Returns:
- a
SslOptions
instance 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
Transport
remote connection details.
-
getLocalPrincipal
Principal getLocalPrincipal()- Returns:
- the local principal for a Transport that is using a secure connection.
-