|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Connection
Public API: Interface to an AMQ connection. See the see the spec for details.
To connect to a broker, fill in a ConnectionParameters and use a ConnectionFactory as follows:
ConnectionParameters params = new ConnectionParameters(); params.setUsername(userName); params.setPassword(password); params.setVirtualHost(virtualHost); params.setRequestedHeartbeat(0); ConnectionFactory factory = new ConnectionFactory(params); Connection conn = factory.newConnection(hostName, AMQP.PROTOCOL.PORT); // Then open a channel: Channel channel = conn.createChannel();Current implementations are thread-safe for code at the client API level, and in fact thread-safe internally except for code within RPC calls.
| Method Summary | |
|---|---|
void |
abort()
Abort this connection and all its channels with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
abort(int timeout)
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)
Abort this connection and all its channels. |
void |
abort(int closeCode,
java.lang.String closeMessage,
int timeout)
Abort this connection and all its channels. |
void |
close()
Close this connection and all its channels with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
close(int timeout)
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)
Close this connection and all its channels. |
void |
close(int closeCode,
java.lang.String closeMessage,
int timeout)
Close this connection and all its channels. |
Channel |
createChannel()
Create a new channel, using an internally allocated channel number. |
Channel |
createChannel(int channelNumber)
Create a new channel, using the specified channel number if possible. |
int |
getChannelMax()
Get the negotiated maximum channel number. |
int |
getFrameMax()
Get the negotiated maximum frame size. |
int |
getHeartbeat()
Get the negotiated heartbeat interval. |
java.lang.String |
getHost()
Retrieve the host. |
Address[] |
getKnownHosts()
Retrieve the known hosts. |
ConnectionParameters |
getParameters()
Retrieve the connection parameters. |
int |
getPort()
Retrieve the port number. |
| Methods inherited from interface com.rabbitmq.client.ShutdownNotifier |
|---|
addShutdownListener, getCloseReason, isOpen, notifyListeners, removeShutdownListener |
| Method Detail |
|---|
java.lang.String getHost()
int getPort()
ConnectionParameters getParameters()
int getChannelMax()
getParameters().ConnectionParameters.getRequestedChannelMax().
int getFrameMax()
getParameters().ConnectionParameters.getRequestedFrameMax().
int getHeartbeat()
getParameters().ConnectionParameters.getRequestedHeartbeat().
Address[] getKnownHosts()
AMQP.Connection.OpenOk open-ok method
Channel createChannel()
throws java.io.IOException
java.io.IOException - if an I/O problem is encountered
Channel createChannel(int channelNumber)
throws java.io.IOException
channelNumber - the channel number to allocate
java.io.IOException - if an I/O problem is encountered
void close()
throws java.io.IOException
AMQP.REPLY_SUCCESS close code
and message 'OK'.
Waits for all the close operations to complete.
java.io.IOException - if an I/O problem is encountered
void close(int closeCode,
java.lang.String closeMessage)
throws java.io.IOException
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 encountered
void close(int timeout)
throws java.io.IOException
AMQP.REPLY_SUCCESS close code
and message 'OK'.
This method behaves in a similar way as 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.
timeout - timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinity
java.io.IOException - if an I/O problem is encountered
void close(int closeCode,
java.lang.String closeMessage,
int timeout)
throws java.io.IOException
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 encounteredvoid abort()
AMQP.REPLY_SUCCESS close code
and message 'OK'.
Forces the connection to close.
Any encountered exceptions in the close operations are silently discarded.
void abort(int closeCode,
java.lang.String closeMessage)
closeCode - the close code (See under "Reply Codes" in the AMQP specification)closeMessage - a message indicating the reason for closing the connectionvoid abort(int timeout)
AMQP.REPLY_SUCCESS close code
and message 'OK'.
This method behaves in a similar way as 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.
timeout - timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinity
void abort(int closeCode,
java.lang.String closeMessage,
int timeout)
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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||