|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.rabbitmq.client.impl.ShutdownNotifierComponent com.rabbitmq.client.impl.AMQConnection
public class AMQConnection
Concrete class representing and managing an AMQP connection to a broker.
To create a broker connection, use ConnectionFactory
. See Connection
for an example.
Field Summary | |
---|---|
static int |
HANDSHAKE_TIMEOUT
Timeout used while waiting for AMQP handshaking to complete (milliseconds) |
Constructor Summary | |
---|---|
AMQConnection(java.lang.String username,
java.lang.String password,
FrameHandler frameHandler,
java.util.concurrent.ExecutorService executor,
java.lang.String virtualHost,
java.util.Map<java.lang.String,java.lang.Object> clientProperties,
int requestedFrameMax,
int requestedChannelMax,
int requestedHeartbeat,
SaslConfig saslConfig)
Construct a new connection using a default ExeceptionHandler |
|
AMQConnection(java.lang.String username,
java.lang.String password,
FrameHandler frameHandler,
java.util.concurrent.ExecutorService executor,
java.lang.String virtualHost,
java.util.Map<java.lang.String,java.lang.Object> clientProperties,
int requestedFrameMax,
int requestedChannelMax,
int requestedHeartbeat,
SaslConfig saslConfig,
ExceptionHandler execeptionHandler)
Construct a new connection |
Method Summary | |
---|---|
void |
abort()
Public API - Abort this connection and all its channels with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
abort(int timeout)
Public API - Abort this connection and all its channels with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
abort(int closeCode,
java.lang.String closeMessage)
Public API - Abort this connection and all its channels. |
void |
abort(int closeCode,
java.lang.String closeMessage,
int timeout)
Public API - Abort this connection and all its channels. |
void |
close()
Public API - Close this connection and all its channels with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
close(int timeout)
Public API - Close this connection and all its channels with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
close(int closeCode,
java.lang.String closeMessage)
Public API - Close this connection and all its channels. |
void |
close(int closeCode,
java.lang.String closeMessage,
boolean initiatedByApplication,
java.lang.Throwable cause)
Protected API - Delegates to the
six-argument close method , passing -1 for the timeout, and
false for the abort flag. |
void |
close(int closeCode,
java.lang.String closeMessage,
boolean initiatedByApplication,
java.lang.Throwable cause,
int timeout,
boolean abort)
Protected API - Close this connection with the given code, message, source and timeout value for all the close operations to complete. |
void |
close(int closeCode,
java.lang.String closeMessage,
int timeout)
Public API - Close this connection and all its channels. |
Channel |
createChannel()
Public API - Create a new channel, using an internally allocated channel number. |
Channel |
createChannel(int channelNumber)
Public API - Create a new channel, using the specified channel number if possible. |
static java.util.Map<java.lang.String,java.lang.Object> |
defaultClientProperties()
Retrieve a copy of the default table of client properties that will be sent to the server during connection startup. |
void |
disconnectChannel(ChannelN channel)
Protected API - respond, in the driver thread, to a ShutdownSignal. |
void |
flush()
Public API - flush the output buffers |
java.net.InetAddress |
getAddress()
Retrieve the host. |
int |
getChannelMax()
Get the negotiated maximum channel number. |
java.util.Map<java.lang.String,java.lang.Object> |
getClientProperties()
Get a copy of the map of client properties sent to the server |
ExceptionHandler |
getExceptionHandler()
Protected API - retrieve the current ExceptionHandler |
FrameHandler |
getFrameHandler()
|
int |
getFrameMax()
Get the negotiated maximum frame size. |
int |
getHeartbeat()
Get the negotiated heartbeat interval. |
int |
getPort()
Retrieve the port number. |
java.util.Map<java.lang.String,java.lang.Object> |
getServerProperties()
Retrieve the server properties. |
void |
handleConnectionClose(Command closeCommand)
|
boolean |
processControlCommand(Command c)
Handles incoming control commands on channel zero. |
void |
setHeartbeat(int heartbeat)
Protected API - set the heartbeat timeout. |
ShutdownSignalException |
shutdown(java.lang.Object reason,
boolean initiatedByApplication,
java.lang.Throwable cause,
boolean notifyRpc)
Protected API - causes all attached channels to terminate (shutdown) with a ShutdownSignal built from the argument, and stops this connection from accepting further work from the application. |
void |
start()
Start up the connection, including the MainLoop thread. |
java.lang.String |
toString()
|
void |
writeFrame(Frame f)
Public API - sends a frame directly to the broker. |
Methods inherited from class com.rabbitmq.client.impl.ShutdownNotifierComponent |
---|
addShutdownListener, getCloseReason, isOpen, notifyListeners, removeShutdownListener, setShutdownCauseIfOpen |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.rabbitmq.client.ShutdownNotifier |
---|
addShutdownListener, getCloseReason, isOpen, notifyListeners, removeShutdownListener |
Field Detail |
---|
public static final int HANDSHAKE_TIMEOUT
Constructor Detail |
---|
public AMQConnection(java.lang.String username, java.lang.String password, FrameHandler frameHandler, java.util.concurrent.ExecutorService executor, java.lang.String virtualHost, java.util.Map<java.lang.String,java.lang.Object> clientProperties, int requestedFrameMax, int requestedChannelMax, int requestedHeartbeat, SaslConfig saslConfig)
username
- name used to establish connectionpassword
- for username
frameHandler
- for sending and receiving frames on this connectionexecutor
- thread pool service for consumer threads for channels on this connectionvirtualHost
- virtual host of this connectionclientProperties
- client info used in negotiating with the serverrequestedFrameMax
- max size of frame offeredrequestedChannelMax
- max number of channels offeredrequestedHeartbeat
- heart-beat in seconds offeredsaslConfig
- sasl configuration hookpublic AMQConnection(java.lang.String username, java.lang.String password, FrameHandler frameHandler, java.util.concurrent.ExecutorService executor, java.lang.String virtualHost, java.util.Map<java.lang.String,java.lang.Object> clientProperties, int requestedFrameMax, int requestedChannelMax, int requestedHeartbeat, SaslConfig saslConfig, ExceptionHandler execeptionHandler)
username
- name used to establish connectionpassword
- for username
frameHandler
- for sending and receiving frames on this connectionexecutor
- thread pool service for consumer threads for channels on this connectionvirtualHost
- virtual host of this connectionclientProperties
- client info used in negotiating with the serverrequestedFrameMax
- max size of frame offeredrequestedChannelMax
- max number of channels offeredrequestedHeartbeat
- heart-beat in seconds offeredsaslConfig
- sasl configuration hookexeceptionHandler
- handler for exceptions using this connectionMethod Detail |
---|
public static final java.util.Map<java.lang.String,java.lang.Object> defaultClientProperties()
Connection.getClientProperties()
public final void disconnectChannel(ChannelN channel)
channel
- the channel to disconnectpublic java.net.InetAddress getAddress()
getAddress
in interface Connection
public int getPort()
getPort
in interface Connection
public FrameHandler getFrameHandler()
public java.util.Map<java.lang.String,java.lang.Object> getServerProperties()
getServerProperties
in interface Connection
public void start() throws java.io.IOException
java.io.IOException
- if an error is encountered
either before, or during, protocol negotiation;
sub-classes ProtocolVersionMismatchException
and
PossibleAuthenticationFailureException
will be thrown in the
corresponding circumstances. If an exception is thrown, connection
resources allocated can all be garbage collected when the connection
object is no longer referenced.public int getChannelMax()
getChannelMax
in interface Connection
public int getFrameMax()
getFrameMax
in interface Connection
public int getHeartbeat()
getHeartbeat
in interface Connection
public void setHeartbeat(int heartbeat)
public java.util.Map<java.lang.String,java.lang.Object> getClientProperties()
Connection
getClientProperties
in interface Connection
public ExceptionHandler getExceptionHandler()
public Channel createChannel(int channelNumber) throws java.io.IOException
createChannel
in interface Connection
channelNumber
- the channel number to allocate
java.io.IOException
- if an I/O problem is encounteredpublic Channel createChannel() throws java.io.IOException
createChannel
in interface Connection
java.io.IOException
- if an I/O problem is encounteredpublic void writeFrame(Frame f) throws java.io.IOException
java.io.IOException
public void flush() throws java.io.IOException
java.io.IOException
public boolean processControlCommand(Command c) throws java.io.IOException
java.io.IOException
ChannelN.processAsync(com.rabbitmq.client.Command)
public void handleConnectionClose(Command closeCommand)
public ShutdownSignalException shutdown(java.lang.Object reason, boolean initiatedByApplication, java.lang.Throwable cause, boolean notifyRpc)
ShutdownListener
s for the
connection are notified when the main loop terminates.
reason
- object being shutdowninitiatedByApplication
- true if caused by a client commandcause
- trigger exception which caused shutdownnotifyRpc
- true if outstanding rpc should be informed of shutdown
public void close() throws java.io.IOException
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
Waits for all the close operations to complete.
close
in interface Connection
java.io.IOException
- if an I/O problem is encounteredpublic void close(int timeout) throws java.io.IOException
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
This method behaves in a similar way as Connection.close()
, with the only difference
that it waits with a provided timeout for all the close operations to
complete. When timeout is reached the socket is forced to close.
close
in interface Connection
timeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinity
java.io.IOException
- if an I/O problem is encounteredpublic void close(int closeCode, java.lang.String closeMessage) throws java.io.IOException
close
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connection
java.io.IOException
- if an I/O problem is encounteredpublic void close(int closeCode, java.lang.String closeMessage, int timeout) throws java.io.IOException
close
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectiontimeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinity
java.io.IOException
- if an I/O problem is encounteredpublic void abort()
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
Forces the connection to close.
Any encountered exceptions in the close operations are silently discarded.
abort
in interface Connection
public void abort(int closeCode, java.lang.String closeMessage)
abort
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectionpublic void abort(int timeout)
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
This method behaves in a similar way as Connection.abort()
, with the only difference
that it waits with a provided timeout for all the close operations to
complete. When timeout is reached the socket is forced to close.
abort
in interface Connection
timeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinitypublic void abort(int closeCode, java.lang.String closeMessage, int timeout)
abort
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectiontimeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinitypublic void close(int closeCode, java.lang.String closeMessage, boolean initiatedByApplication, java.lang.Throwable cause) throws java.io.IOException
the
six-argument close method
, passing -1 for the timeout, and
false for the abort flag.
java.io.IOException
public void close(int closeCode, java.lang.String closeMessage, boolean initiatedByApplication, java.lang.Throwable cause, int timeout, boolean abort) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |