public interface IConnection

Known direct subtypes: AutorecoveringConnection, Connection

Summary

Main interface to an AMQP connection.

Remarks

Instances of are used to create fresh sessions/channels. The class is used to construct 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 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 channel number this connection supports (0 if unlimited). Usable channel numbers range from 1 to this number, inclusive.

IDictionary<string,object> ClientProperties (r)

A copy of the client properties that has been sent to the server.

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.

ConsumerWorkService ConsumerWorkService (r)

(undocumented)

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 equal 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.

IProtocol Protocol (r)

The this connection is using to communicate with its peer.

IDictionary<string,object> ServerProperties (r)

A dictionary of the server properties sent by the server while establishing the connection. This typically includes the product name and version of the server.

IList<ShutdownReportEntry> ShutdownReport (r)

Returns the list of objects that contain information about any errors reported while closing the connection in the order they appeared

Event Summary

Type Name Summary
EventHandler<CallbackExceptionEventArgs> CallbackException

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

EventHandler<ConnectionBlockedEventArgs> ConnectionBlocked

(undocumented)

EventHandler<ShutdownEventArgs> ConnectionShutdown

Raised when the connection is destroyed.

EventHandler<EventArgs> ConnectionUnblocked

(undocumented)

Method Summary

Name Summary
void Abort()

Abort this connection and all its channels.

void Abort(ushort reasonCode, string reasonText)

Abort this connection and all its channels.

void Abort(int timeout)

Abort this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

void Abort(ushort reasonCode, string reasonText, int timeout)

Abort this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

void Close()

Close this connection and all its channels.

void Close(int timeout)

Close this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

void Close(ushort reasonCode, string reasonText, int timeout)

Close this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

void Close(ushort reasonCode, string reasonText)

Close this connection and all its channels.

IModel CreateModel()

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

void HandleConnectionBlocked(string reason)

Handle incoming Connection.Blocked methods.

void HandleConnectionUnblocked()

Handle incoming Connection.Unblocked methods.

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 channel number this connection supports (0 if unlimited). Usable channel numbers range from 1 to this number, inclusive.

IDictionary<string,object> ClientProperties (r)

Summary

A copy of the client properties that has been sent to the server.

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 , seeing it is null (meaning the was available for use at the time of the check), and interpreting this mistakenly as a guarantee that the will remain usable for a time. Instead, the operation of interest should simply be attempted: if the is not in a usable state, an exception will be thrown (most likely , but may vary depending on the particular operation being attempted).

ConsumerWorkService ConsumerWorkService (r)

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 equal 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.

IProtocol Protocol (r)

Summary

The this connection is using to communicate with its peer.

IDictionary<string,object> ServerProperties (r)

Summary

A dictionary of the server properties sent by the server while establishing the connection. This typically includes the product name and version of the server.

IList<ShutdownReportEntry> ShutdownReport (r)

Summary

Returns the list of objects that contain information about any errors reported while closing the connection in the order they appeared

Event Detail

EventHandler<CallbackExceptionEventArgs> 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 , then this event will be signalled whenever one of those event handlers throws an exception, as well.

EventHandler<ConnectionBlockedEventArgs> ConnectionBlocked

EventHandler<ShutdownEventArgs> 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.

EventHandler<EventArgs> ConnectionUnblocked

Method Detail

Abort

void Abort()

Return type void

Summary

Abort this connection and all its channels.

Remarks

Note that all active channels, sessions, and models will be closed if this method is called. In comparison to normal method, will not throw or during closing connection. This method waits infinitely for the in-progress close operation to complete.

Abort

void Abort(ushort reasonCode, string reasonText)

Return type void
Parameters
Name Type
reasonCode ushort
reasonText string

Summary

Abort this connection and all its channels.

Remarks

The method behaves in the same way as , with the only difference that the connection is closed with the given connection close code and message.

The close code (See under "Reply Codes" in the AMQP specification)

A message indicating the reason for closing the connection

Abort

void Abort(int timeout)

Return type void
Parameters
Name Type
timeout int

Summary

Abort this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

Remarks

This method, behaves in a similar way as method with the only difference that it explictly specifies the timeout given for all the in-progress close operations to complete. If timeout is reached and the close operations haven't finished, then socket is forced to close.

To wait infinitely for the close operations to complete use .

Abort

void Abort(ushort reasonCode, string reasonText, int timeout)

Return type void
Parameters
Name Type
reasonCode ushort
reasonText string
timeout int

Summary

Abort this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

Remarks

The method behaves in the same way as , with the only difference that the connection is closed with the given connection close code and message.

The close code (See under "Reply Codes" in the AMQP specification).

A message indicating the reason for closing the connection.

Close

void Close()

Return type void

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. It will wait for the in-progress close operation to complete. This method will not return to the caller until the shutdown is complete. If the connection is already closed (or closing), then this method will throw . It can also throw when socket was closed unexpectedly.

Close

void Close(int timeout)

Return type void
Parameters
Name Type
timeout int

Summary

Close this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

Remarks

Note that all active channels, sessions, and models will be closed if this method is called. It will wait for the in-progress close operation to complete with a timeout. If the connection is already closed (or closing), then this method will throw . It can also throw when socket was closed unexpectedly. If timeout is reached and the close operations haven't finished, then socket is forced to close.

To wait infinitely for the close operations to complete use .

Close

void Close(ushort reasonCode, string reasonText, int timeout)

Return type void
Parameters
Name Type
reasonCode ushort
reasonText string
timeout int

Summary

Close this connection and all its channels and wait with a timeout for all the in-progress close operations to complete.

Remarks

The method behaves in the same way as , with the only difference that the connection is closed with the given connection close code and message.

The close code (See under "Reply Codes" in the AMQP specification).

A message indicating the reason for closing the connection.

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

The method behaves in the same way as , with the only difference that the connection is closed with the given connection close code and message.

The close code (See under "Reply Codes" in the AMQP specification).

A message indicating the reason for closing the connection.

CreateModel

IModel CreateModel()

Return type IModel

Summary

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

HandleConnectionBlocked

void HandleConnectionBlocked(string reason)

Return type void
Parameters
Name Type
reason string

Summary

Handle incoming Connection.Blocked methods.

HandleConnectionUnblocked

void HandleConnectionUnblocked()

Return type void

Summary

Handle incoming Connection.Unblocked methods.