public interface IConnection

Known direct subtypes: ConnectionBase

Summary

Main interface to an AMQP connection.

Remarks

Instances of IConnection are used to create fresh sessions/channels. The ConnectionFactory class is used to construct IConnection instances. Please see the documentation for ConnectionFactory for an example of usage. Alternatively, an API tutorial can be found in the User Guide.

Extends the IDisposable interface, so that the "using" statement can be used to scope the lifetime of a channel when appropriate.

Property Summary

Type Name Summary
bool AutoClose (rw)

If true, will close the whole connection as soon as there are no channels open on it; if false, manual connection closure will be required.

ushort ChannelMax (r)

The maximum number of channels this connection supports (0 if unlimited).

ShutdownEventArgs CloseReason (r)

Returns null if the connection is still in a state where it can be used, or the cause of its closure otherwise.

AmqpTcpEndpoint Endpoint (r)

Retrieve the endpoint this connection is connected to.

uint FrameMax (r)

The maximum frame size this connection supports (0 if unlimited).

ushort Heartbeat (r)

The current heartbeat setting for this connection (0 for disabled), in seconds.

bool IsOpen (r)

Returns true if the connection is still in a state where it can be used. Identical to checking if CloseReason == null.

AmqpTcpEndpoint[] KnownHosts (r)

Returns the known hosts that came back from the broker in the connection.open-ok method at connection startup time. Null until the connection is completely open and ready for use.

ConnectionParameters Parameters (r)

The connection parameters used during construction of this connection.

IProtocol Protocol (r)

The IProtocol this connection is using to communicate with its peer.

Event Summary

Type Name Summary
CallbackExceptionEventHandler CallbackException

Signalled when an exception occurs in a callback invoked by the connection.

ConnectionShutdownEventHandler ConnectionShutdown

Raised when the connection is destroyed.

Method Summary

Name Summary
void Close(ushort reasonCode, string reasonText)

Close this connection and all its channels.

IModel CreateModel()

Create and return a fresh channel, session, and model.

Property Detail

bool AutoClose (rw)

Summary

If true, will close the whole connection as soon as there are no channels open on it; if false, manual connection closure will be required.

Remarks

Don't set AutoClose to true before opening the first channel, because the connection will be immediately closed if you do!

ushort ChannelMax (r)

Summary

The maximum number of channels this connection supports (0 if unlimited).

ShutdownEventArgs CloseReason (r)

Summary

Returns null if the connection is still in a state where it can be used, or the cause of its closure otherwise.

Remarks

Applications should use the ConnectionShutdown event to avoid race conditions. The scenario to avoid is checking CloseReason, seeing it is null (meaning the IConnection was available for use at the time of the check), and interpreting this mistakenly as a guarantee that the IConnection will remain usable for a time. Instead, the operation of interest should simply be attempted: if the IConnection is not in a usable state, an exception will be thrown (most likely OperationInterruptedException, but may vary depending on the particular operation being attempted).

AmqpTcpEndpoint Endpoint (r)

Summary

Retrieve the endpoint this connection is connected to.

uint FrameMax (r)

Summary

The maximum frame size this connection supports (0 if unlimited).

ushort Heartbeat (r)

Summary

The current heartbeat setting for this connection (0 for disabled), in seconds.

bool IsOpen (r)

Summary

Returns true if the connection is still in a state where it can be used. Identical to checking if CloseReason == null.

AmqpTcpEndpoint[] KnownHosts (r)

Summary

Returns the known hosts that came back from the broker in the connection.open-ok method at connection startup time. Null until the connection is completely open and ready for use.

ConnectionParameters Parameters (r)

Summary

The connection parameters used during construction of this connection.

IProtocol Protocol (r)

Summary

The IProtocol this connection is using to communicate with its peer.

Event Detail

CallbackExceptionEventHandler CallbackException

Summary

Signalled when an exception occurs in a callback invoked by the connection.

Remarks

This event is signalled when a ConnectionShutdown handler throws an exception. If, in future, more events appear on IConnection, then this event will be signalled whenever one of those event handlers throws an exception, as well.

ConnectionShutdownEventHandler ConnectionShutdown

Summary

Raised when the connection is destroyed.

Remarks

If the connection is already destroyed at the time an event handler is added to this event, the event handler will be fired immediately.

Method Detail

Close

void Close(ushort reasonCode, string reasonText)

Return type void
Parameters
Name Type
reasonCode ushort
reasonText string

Summary

Close this connection and all its channels.

Remarks

Note that all active channels, sessions, and models will be closed if this method is called. If the connection is already closed (or closing), then this method does nothing but wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete.

CreateModel

IModel CreateModel()

Return type IModel

Summary

Create and return a fresh channel, session, and model.