class: RabbitMqConnection
[30:14] (extern: com.lehman.aussom.RabbitMqConnection) extends: object
Connection to a RabbitMQ server. Configure with one AMQP URI (amqp://user:pass@host:5672/vhost, or amqps://... for TLS) or with the piecewise setters; nothing touches the network until connect() is called. Configuration setters apply at connect() time, so call them first. The connection is long-lived and thread safe; channels opened from it are not. Use each channel from one thread only.
Methods
-
RabbitMqConnection (
string Uri = null)Creates a connection definition.
- @p
Uriis a string with the AMQP URI (optional - the piecewise setters work instead).
- @p
-
newConnection (
string Uri = null) -
setUri (
string Uri)Sets the AMQP URI. Call before connect().
- @p
Uriis a string with the amqp:// or amqps:// URI. - @r
thisobject
- @p
-
setHost (
string Host)Sets the broker host name. Default localhost. Call before connect().
- @p
Hostis a string with the host name. - @r
thisobject
- @p
-
setPort (
int Port)Sets the broker port. Default 5672 (5671 with TLS). Call before connect().
- @p
Portis an int with the port number. - @r
thisobject
- @p
-
setVirtualHost (
string VHost)Sets the virtual host. Default "/". Call before connect().
- @p
VHostis a string with the virtual host. - @r
thisobject
- @p
-
setUser (
string User, string Password = null)Sets credentials. Default guest/guest, which RabbitMQ itself only accepts from localhost. Call before connect().
- @p
Useris a string with the user name. - @p
Passwordis a string with the password (optional). - @r
thisobject
- @p
-
setConnectionName (
string Name)Sets the client-provided connection name shown in the broker's management UI. Call before connect().
- @p
Nameis a string with the connection name. - @r
thisobject
- @p
-
addAddress (
string Host, int Port = null)Adds an endpoint to the address list. When addresses are set, connect() tries them in order - RabbitMQ's equivalent of a failover URL list. Call before connect().
- @p
Hostis a string with the host name. - @p
Portis an int with the port (optional, default per scheme). - @r
thisobject
- @p
-
setHeartbeat (
int Seconds)Sets the requested heartbeat interval. Default 60. Call before connect().
- @p
Secondsis an int with the heartbeat interval in seconds. - @r
thisobject
- @p
-
setConnectionTimeoutMs (
int Ms)Sets the TCP connect timeout. Call before connect().
- @p
Msis an int with the timeout in milliseconds. - @r
thisobject
- @p
-
setAutomaticRecovery (
bool On)Enables or disables automatic connection recovery: the client transparently reconnects and re-opens channels after a network failure. Default true. Call before connect().
- @p
Onis a bool with true to enable recovery. - @r
thisobject
- @p
-
setTopologyRecovery (
bool On)Enables or disables topology recovery: re-declaring queues, exchanges, bindings, and consumers after a reconnect. Default true. Call before connect().
- @p
Onis a bool with true to enable topology recovery. - @r
thisobject
- @p
-
setNetworkRecoveryIntervalMs (
int Ms)Sets the delay between automatic recovery attempts. Default 5000. Call before connect().
- @p
Msis an int with the recovery interval in milliseconds. - @r
thisobject
- @p
-
setChannelMax (
int Max)Sets the requested channel-max protocol limit. Rarely needed. Call before connect().
- @p
Maxis an int with the channel limit. - @r
thisobject
- @p
-
setFrameMax (
int Bytes)Sets the requested frame-max protocol limit. Rarely needed. Call before connect().
- @p
Bytesis an int with the frame limit in bytes. - @r
thisobject
- @p
-
setClientProperty (
string Name, Value)Adds a client property sent to the broker at handshake and shown in the management UI. Call before connect().
- @p
Nameis a string with the property name. - @p
Valueis the property value (string/int/double/bool). - @r
thisobject
- @p
-
useTls ()
Enables TLS using the JVM's default truststore, with hostname verification. Call before connect().
- @r
thisobject
- @r
-
useTlsNoVerify ()
Dev-only: enables TLS without certificate verification, so self-signed certs are accepted. A warning is logged at connect time. Do not use in production. Call before connect().
- @r
thisobject
- @r
-
connect ()
Builds the factory from the stored configuration and opens the connection.
- @r
thisobject
- @r
-
openChannel ()
Opens a new channel on this connection. Use each channel from one thread only.
- @r
Anew RabbitMqChannel object.
- @r
-
isConnected ()
Reports whether the connection is open.
- @r
Abool with true while connected.
- @r
-
isOpen ()
Alias of isConnected().
- @r
Abool with true while connected.
- @r
-
isBlocked ()
Reports whether the broker has blocked this connection because of a resource alarm. Publishing while blocked stalls.
- @r
Abool with true while blocked.
- @r
-
getServerProperties ()
Gets the broker-announced server properties (product, version, capabilities).
- @r
Amap with the server properties.
- @r
-
close (
int TimeoutMs = null)Closes the connection and every channel created from it. Safe to call more than once.
- @p
TimeoutMsis an int bounding the orderly shutdown (optional, default waits indefinitely). - @r
thisobject
- @p
-
abort ()
Forces the connection closed without waiting for protocol shutdown. Never errors. Safe to call more than once.
- @r
thisobject
- @r