Show / Hide Table of Contents

# Class Connection

Represents a connection with a message broker

##### Inheritance

System.Object
Connection
NetTxConnection

##### Implements

Apache.NMS.IConnection
System.IDisposable
Apache.NMS.IStartable
Apache.NMS.IStoppable

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Apache.NMS.ActiveMQ

###### Assembly: Apache.NMS.ActiveMQ.dll

##### Syntax

    public class Connection : IConnection, IDisposable, IStartable, IStoppable

### Constructors

| Improve this Doc View Source

#### Connection(Uri, ITransport, IdGenerator)

##### Declaration

    public Connection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Uri | connectionUri |
ITransport | transport |
IdGenerator | clientIdGenerator |

### Properties

| Improve this Doc View Source

#### AckMode

This property sets the acknowledgment mode for the connection. The URI parameter connection.ackmode can be set to a string value that maps to the enumeration value.

##### Declaration

    public string AckMode { set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### AcknowledgementMode

##### Declaration

    public AcknowledgementMode AcknowledgementMode { get; set; }

##### Property Value

Type | Description
--- | ---
Apache.NMS.AcknowledgementMode |

| Improve this Doc View Source

#### AlwaysSyncSend

This property forces all messages that are sent to be sent synchronously overriding any usage of the AsyncSend flag. This can reduce performance in some cases since the only messages we normally send synchronously are Persistent messages not sent in a transaction. This options guarantees that no send will return until the broker has acknowledge receipt of the message

##### Declaration

    public bool AlwaysSyncSend { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### AsyncClose

This property indicates whether or not async close is enabled. When the connection is closed, it will either send a synchronous DisposeOf command to the broker and wait for confirmation (if true), or it will send the DisposeOf command asynchronously.

##### Declaration

    public bool AsyncClose { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### AsyncSend

This property indicates whether or not async send is enabled.

##### Declaration

    public bool AsyncSend { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### AuditDepth

##### Declaration

    public int AuditDepth { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### AuditMaximumProducerNumber

##### Declaration

    public int AuditMaximumProducerNumber { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### BrokerInfo

##### Declaration

    public BrokerInfo BrokerInfo { get; }

##### Property Value

Type | Description
--- | ---
BrokerInfo |

| Improve this Doc View Source

#### BrokerUri

##### Declaration

    public Uri BrokerUri { get; }

##### Property Value

Type | Description
--- | ---
System.Uri |

| Improve this Doc View Source

#### BrokerWireFormat

##### Declaration

    public WireFormatInfo BrokerWireFormat { get; }

##### Property Value

Type | Description
--- | ---
WireFormatInfo |

| Improve this Doc View Source

#### CheckForDuplicates

##### Declaration

    public bool CheckForDuplicates { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### ClientId

##### Declaration

    public string ClientId { get; set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### CompressionPolicy

##### Declaration

    public ICompressionPolicy CompressionPolicy { get; set; }

##### Property Value

Type | Description
--- | ---
ICompressionPolicy |

| Improve this Doc View Source

#### ConnectionId

##### Declaration

    public ConnectionId ConnectionId { get; }

##### Property Value

Type | Description
--- | ---
ConnectionId |

| Improve this Doc View Source

#### ConsumerFailoverRedeliveryWaitPeriod

##### Declaration

    public long ConsumerFailoverRedeliveryWaitPeriod { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int64 |

| Improve this Doc View Source

#### ConsumerTransformer

##### Declaration

    public ConsumerTransformerDelegate ConsumerTransformer { get; set; }

##### Property Value

Type | Description
--- | ---
Apache.NMS.ConsumerTransformerDelegate |

| Improve this Doc View Source

#### CopyMessageOnSend

This property indicates whether Message's should be copied before being sent via one of the Connection's send methods. Copying the Message object allows the user to resuse the Object over for another send. If the message isn't copied performance can improve but the user must not reuse the Object as it may not have been sent before they reset its payload.

##### Declaration

    public bool CopyMessageOnSend { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### DefaultClientId

The Default Client Id used if the ClientId property is not set explicity.

##### Declaration

    public string DefaultClientId { set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### DispatchAsync

synchronously or asynchronously by the broker.

##### Declaration

    public bool DispatchAsync { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### ExclusiveConsumer

##### Declaration

    public bool ExclusiveConsumer { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### FirstFailureError

##### Declaration

    public Exception FirstFailureError { get; }

##### Property Value

Type | Description
--- | ---
System.Exception |

| Improve this Doc View Source

#### IsStarted

This property determines if the asynchronous message delivery of incoming messages has been started for this connection.

##### Declaration

    public bool IsStarted { get; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### ITransport

##### Declaration

    public ITransport ITransport { get; set; }

##### Property Value

Type | Description
--- | ---
ITransport |

| Improve this Doc View Source

#### MessagePrioritySupported

Indicate whether or not the resources of this Connection should support the Message Priority value of incoming messages and dispatch them accordingly. When disabled Message are always dispatched to Consumers in FIFO order.

##### Declaration

    public bool MessagePrioritySupported { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### MetaData

##### Declaration

    public IConnectionMetaData MetaData { get; }

##### Property Value

Type | Description
--- | ---
Apache.NMS.IConnectionMetaData |

| Improve this Doc View Source

#### NextSessionId

##### Declaration

    protected SessionId NextSessionId { get; }

##### Property Value

Type | Description
--- | ---
SessionId |

| Improve this Doc View Source

#### NonBlockingRedelivery

##### Declaration

    public bool NonBlockingRedelivery { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### OptimizeAcknowledge

##### Declaration

    public bool OptimizeAcknowledge { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### OptimizeAcknowledgeTimeOut

##### Declaration

    public long OptimizeAcknowledgeTimeOut { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int64 |

| Improve this Doc View Source

#### OptimizedAckScheduledAckInterval

##### Declaration

    public long OptimizedAckScheduledAckInterval { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int64 |

| Improve this Doc View Source

#### Password

##### Declaration

    public string Password { get; set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### PrefetchPolicy

##### Declaration

    public PrefetchPolicy PrefetchPolicy { get; set; }

##### Property Value

Type | Description
--- | ---
PrefetchPolicy |

| Improve this Doc View Source

#### ProducerTransformer

##### Declaration

    public ProducerTransformerDelegate ProducerTransformer { get; set; }

##### Property Value

Type | Description
--- | ---
Apache.NMS.ProducerTransformerDelegate |

| Improve this Doc View Source

#### ProducerWindowSize

This property is the maximum number of bytes in memory that a producer will transmit to a broker before waiting for acknowledgement messages from the broker that it has accepted the previously sent messages. In other words, this how you configure the producer flow control window that is used for async sends where the client is responsible for managing memory usage. The default value of 0 means no flow control at the client

##### Declaration

    public int ProducerWindowSize { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### ProtocolVersion

This property indicates what version of the Protocol we are using to communicate with the Broker, if not set we return the lowest version number to indicate we support only the basic command set.

##### Declaration

    public int ProtocolVersion { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

| Improve this Doc View Source

#### RedeliveryPolicy

Get/or set the redelivery policy for this connection.

##### Declaration

    public IRedeliveryPolicy RedeliveryPolicy { get; set; }

##### Property Value

Type | Description
--- | ---
Apache.NMS.IRedeliveryPolicy |

| Improve this Doc View Source

#### RequestTimeout

##### Declaration

    public TimeSpan RequestTimeout { get; set; }

##### Property Value

Type | Description
--- | ---
System.TimeSpan |

| Improve this Doc View Source

#### ResourceManagerId

##### Declaration

    public string ResourceManagerId { get; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### SendAcksAsync

This property indicates whether or not async sends are used for message acknowledgement messages. Sending Acks async can improve performance but may decrease reliability.

##### Declaration

    public bool SendAcksAsync { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### TransactedIndividualAck

##### Declaration

    public bool TransactedIndividualAck { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### TransportFailed

##### Declaration

    public bool TransportFailed { get; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### UseCompression

Enable or Disable the use of Compression on Message bodies. When enabled all messages have their body compressed using the Deflate compression algorithm. The recipient of the message must support the use of message compression as well otherwise the receiving client will receive a message whose body appears in the compressed form.

##### Declaration

    public bool UseCompression { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### UseRetroactiveConsumer

##### Declaration

    public bool UseRetroactiveConsumer { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### UserName

##### Declaration

    public string UserName { get; set; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### WatchTopicAdvisories

##### Declaration

    public bool WatchTopicAdvisories { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

### Methods

| Improve this Doc View Source

#### CheckClosed()

##### Declaration

    protected void CheckClosed()

| Improve this Doc View Source

#### CheckClosedOrFailed()

##### Declaration

    protected void CheckClosedOrFailed()

| Improve this Doc View Source

#### Close()

##### Declaration

    public void Close()

| Improve this Doc View Source

#### CreateActiveMQSession(AcknowledgementMode)

##### Declaration

    protected virtual Session CreateActiveMQSession(AcknowledgementMode ackMode)

##### Parameters

Type | Name | Description
--- | --- | ---
Apache.NMS.AcknowledgementMode | ackMode |

##### Returns

Type | Description
--- | ---
Session |

| Improve this Doc View Source

#### CreateLocalTransactionId()

Creates a new local transaction ID

##### Declaration

    public LocalTransactionId CreateLocalTransactionId()

##### Returns

Type | Description
--- | ---
LocalTransactionId |

| Improve this Doc View Source

#### CreateSession()

Creates a new session to work on this connection

##### Declaration

    public ISession CreateSession()

##### Returns

Type | Description
--- | ---
Apache.NMS.ISession |

| Improve this Doc View Source

#### CreateSession(AcknowledgementMode)

Creates a new session to work on this connection

##### Declaration

    public ISession CreateSession(AcknowledgementMode sessionAcknowledgementMode)

##### Parameters

Type | Name | Description
--- | --- | ---
Apache.NMS.AcknowledgementMode | sessionAcknowledgementMode |

##### Returns

Type | Description
--- | ---
Apache.NMS.ISession |

| Improve this Doc View Source

#### CreateTemporaryDestination(Boolean)

##### Declaration

    public ActiveMQTempDestination CreateTemporaryDestination(bool topic)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | topic |

##### Returns

Type | Description
--- | ---
ActiveMQTempDestination |

| Improve this Doc View Source

#### DeleteDestination(IDestination)

##### Declaration

    public void DeleteDestination(IDestination destination)

##### Parameters

Type | Name | Description
--- | --- | ---
Apache.NMS.IDestination | destination |

| Improve this Doc View Source

#### DeleteTemporaryDestination(IDestination)

##### Declaration

    public void DeleteTemporaryDestination(IDestination destination)

##### Parameters

Type | Name | Description
--- | --- | ---
Apache.NMS.IDestination | destination |

| Improve this Doc View Source

#### DispatchMessage(MessageDispatch)

##### Declaration

    protected void DispatchMessage(MessageDispatch dispatch)

##### Parameters

Type | Name | Description
--- | --- | ---
MessageDispatch | dispatch |

| Improve this Doc View Source

#### Dispose()

##### Declaration

    public void Dispose()

| Improve this Doc View Source

#### Dispose(Boolean)

##### Declaration

    protected void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | disposing |

| Improve this Doc View Source

#### Finalize()

##### Declaration

    protected void Finalize()

| Improve this Doc View Source

#### OnCommand(ITransport, Command)

Handle incoming commands

##### Declaration

    protected void OnCommand(ITransport commandTransport, Command command)

##### Parameters

Type | Name | Description
--- | --- | ---
ITransport | commandTransport | An ITransport
Command | command | A Command

| Improve this Doc View Source

#### Oneway(Command)

##### Declaration

    public void Oneway(Command command)

##### Parameters

Type | Name | Description
--- | --- | ---
Command | command |

| Improve this Doc View Source

#### OnKeepAliveCommand(ITransport, KeepAliveInfo)

##### Declaration

    protected void OnKeepAliveCommand(ITransport commandTransport, KeepAliveInfo info)

##### Parameters

Type | Name | Description
--- | --- | ---
ITransport | commandTransport |
KeepAliveInfo | info |

| Improve this Doc View Source

#### OnTransportInterrupted(ITransport)

##### Declaration

    protected void OnTransportInterrupted(ITransport sender)

##### Parameters

Type | Name | Description
--- | --- | ---
ITransport | sender |

| Improve this Doc View Source

#### OnTransportResumed(ITransport)

##### Declaration

    protected void OnTransportResumed(ITransport sender)

##### Parameters

Type | Name | Description
--- | --- | ---
ITransport | sender |

| Improve this Doc View Source

#### PurgeTempDestinations()

##### Declaration

    public void PurgeTempDestinations()

| Improve this Doc View Source

#### Start()

Starts asynchronous message delivery of incoming messages for this connection. Synchronous delivery is unaffected.

##### Declaration

    public void Start()

| Improve this Doc View Source

#### Stop()

Temporarily stop asynchronous delivery of inbound messages for this connection. The sending of outbound messages is unaffected.

##### Declaration

    public void Stop()

| Improve this Doc View Source

#### SyncRequest(Command)

Performs a synchronous request-response with the broker

##### Declaration

    public Response SyncRequest(Command command)

##### Parameters

Type | Name | Description
--- | --- | ---
Command | command |

##### Returns

Type | Description
--- | ---
Response |

| Improve this Doc View Source

#### SyncRequest(Command, TimeSpan)

Performs a synchronous request-response with the broker for requested timeout duration.

##### Declaration

    public Response SyncRequest(Command command, TimeSpan requestTimeout)

##### Parameters

Type | Name | Description
--- | --- | ---
Command | command |
System.TimeSpan | requestTimeout |

##### Returns

Type | Description
--- | ---
Response |

### Events

| Improve this Doc View Source

#### ConnectionInterruptedListener

An asynchronous listener that is notified when a Fault tolerant connection has been interrupted.

##### Declaration

    public event ConnectionInterruptedListener ConnectionInterruptedListener

##### Event Type

Type | Description
--- | ---
Apache.NMS.ConnectionInterruptedListener |

| Improve this Doc View Source

#### ConnectionResumedListener

An asynchronous listener that is notified when a Fault tolerant connection has been resumed.

##### Declaration

    public event ConnectionResumedListener ConnectionResumedListener

##### Event Type

Type | Description
--- | ---
Apache.NMS.ConnectionResumedListener |

| Improve this Doc View Source

#### ExceptionListener

A delegate that can receive transport level exceptions.

##### Declaration

    public event ExceptionListener ExceptionListener

##### Event Type

Type | Description
--- | ---
Apache.NMS.ExceptionListener |

### Implements

Apache.NMS.IConnection
System.IDisposable
Apache.NMS.IStartable
Apache.NMS.IStoppable