Show / Hide Table of Contents

Class ContainerHost

The ContainerHost class hosts an AMQP container where connection listeners can be created to accept client requests.

Inheritance
System.Object
ContainerHost
Implements
IContainerHost
IContainer
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Amqp.Listener
Assembly: Amqp.Net.dll
Syntax
public class ContainerHost : IContainerHost, IContainer
Remarks

A container has one or more connection endpoints where transport listeners are created.

Message-level Processing

  • IMessageProcessor: message processors can be registered to accept incoming messages (one-way incoming).
  • IMessageSource: message sources can be registered to handle receive requests (one-way outgoing).
  • IRequestProcessor: request processors can be registered to process request messages and send back response (two-way).

Link-level Processing Message level processing only deals with incoming and outgoing messages without worrying about the links.

  • ILinkProcessor: link processors can be registered to process received attach performatives. This is useful when the application needs to participate in link attach/detach for extra resource allocation/cleanup, or perform additional validation and security enforcement at the link level.
  • Link processors create LinkEndpoint objects which can be either message sink or message source. Application can create custom LinkEndpoint class to handle all link events (flow, transfer and disposition). However, it is recommended to use the built-in LinkEndpoint classes.
  • TargetLinkEndpoint: a TargetLinkEndpoint simply forwards the request to the IMessageProcessor.
  • SourceLinkEndpoint: a SourceLinkEndpoint manages link credit and transforms flow state into a receive loop on the IMessageSource. Delivery acknowledgements are simply forwarded to the IMessageSource.

When per-link handling is required, it is recommended to combine message level processing with link level processing.

  • An IMessageProcessor/Source should be implemented.
  • After the link attach is handled, wrap it in a Target/SourceLinkEndpoint that works with the previously implemented message processor or source.

Upon receiving an attach performative, the registered message level processors (IMessageProcessor, IMessageSource, IRequestProcessor) are checked first. If a processor matches the address on the received attach performative, a link is automatically created and the send/receive requests will be routed to the associated processor. Otherwise, the registered link processor, if any, is invoked to create a LinkEndpoint, where subsequent send/receive requests will be routed. When none is found, the link is detached with error "amqp:not-found".

Constructors

ContainerHost(Address)

Initializes a container host object with one address. The address.

Declaration
public ContainerHost(Address address)
Parameters
Type Name Description
Address address

ContainerHost(IList<Address>)

Initializes a container host object with multiple addresses. The list of listen addresses.

Declaration
public ContainerHost(IList<Address> addressList)
Parameters
Type Name Description
System.Collections.Generic.IList<Address> addressList

ContainerHost(IList<Address>, X509Certificate2)

Initializes a container host object with multiple addresses. The list of listen addresses. The service certificate for TLS.

Declaration
public ContainerHost(IList<Address> addressList, X509Certificate2 certificate)
Parameters
Type Name Description
System.Collections.Generic.IList<Address> addressList
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate

ContainerHost(IList<String>)

Initializes a container host object with multiple addresses.

Declaration
public ContainerHost(IList<string> addressList)
Parameters
Type Name Description
System.Collections.Generic.IList<System.String> addressList

The list of listen addresses.

Remarks

Transport and protocol settings (TCP, SSL, SASL and AMQP) can be set on the listeners of the host after it is created.

ContainerHost(IList<Uri>, X509Certificate2, String)

Initializes a container host object with multiple addresses.

Declaration
[Obsolete("Use ContainerHost(IList<Address>, X509Certificate2) instead.")]
public ContainerHost(IList<Uri> addressUriList, X509Certificate2 certificate, string userInfo)
Parameters
Type Name Description
System.Collections.Generic.IList<System.Uri> addressUriList

The list of listen addresses.

System.Security.Cryptography.X509Certificates.X509Certificate2 certificate

The service certificate for TLS.

System.String userInfo

The credentials required by SASL PLAIN authentication. It is of form "user:password" (parts are URL encoded).

ContainerHost(Uri)

Initializes a container host object with one address.

Declaration
[Obsolete("Use ContainerHost(Address) instead.")]
public ContainerHost(Uri addressUri)
Parameters
Type Name Description
System.Uri addressUri

The address Uri. Only the scheme, host and port parts are used. Supported schemes are "amqp", "amqps", "ws" and "wss".

Properties

CustomTransports

Gets the collection of custom transport providers. Key is the address scheme.

Declaration
public IDictionary<string, TransportProvider> CustomTransports { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<System.String, TransportProvider>

Listeners

Gets a list of connection listeners in this container.

Declaration
public IList<ConnectionListener> Listeners { get; }
Property Value
Type Description
System.Collections.Generic.IList<ConnectionListener>

Methods

Close()

Closes the container host object.

Declaration
public void Close()

Open()

Opens the container host object.

Declaration
public void Open()

RegisterLinkProcessor(ILinkProcessor)

Registers a link processor to handle received attach performatives.

Declaration
public void RegisterLinkProcessor(ILinkProcessor linkProcessor)
Parameters
Type Name Description
ILinkProcessor linkProcessor

The link processor to be registered.

RegisterMessageProcessor(String, IMessageProcessor)

Registers a message processor to accept incoming messages from the specified address. When it is called, the container creates a node where the client can attach.

Declaration
public void RegisterMessageProcessor(string address, IMessageProcessor messageProcessor)
Parameters
Type Name Description
System.String address

The address.

IMessageProcessor messageProcessor

The message processor to be registered.

RegisterMessageSource(String, IMessageSource)

Registers a message source at the specified address where client receives messages. When it is called, the container creates a node where the client can attach.

Declaration
public void RegisterMessageSource(string address, IMessageSource messageSource)
Parameters
Type Name Description
System.String address

The address.

IMessageSource messageSource

The message source to be registered.

RegisterRequestProcessor(String, IRequestProcessor)

Registers a request processor from the specified address.

Declaration
public void RegisterRequestProcessor(string address, IRequestProcessor requestProcessor)
Parameters
Type Name Description
System.String address

The address.

IRequestProcessor requestProcessor

The request processor to be registered.

Remarks

Client must create a pair of links (sending and receiving) at the address. The source.address on the sending link should contain an unique address in the client and it should be specified in target.address on the receiving link.

UnregisterLinkProcessor(ILinkProcessor)

Unregisters a link processor that was previously registered.

Declaration
public void UnregisterLinkProcessor(ILinkProcessor linkProcessor)
Parameters
Type Name Description
ILinkProcessor linkProcessor

The link processor to unregister.

Remarks

If the linkProcessor was not registered or is different from the current registered one, an exception is thrown.

UnregisterMessageProcessor(String)

Unregisters a message processor at the specified address.

Declaration
public void UnregisterMessageProcessor(string address)
Parameters
Type Name Description
System.String address

The address.

UnregisterMessageSource(String)

Unregisters a message source at the specified address.

Declaration
public void UnregisterMessageSource(string address)
Parameters
Type Name Description
System.String address

The address.

UnregisterRequestProcessor(String)

Unregisters a request processor at the specified address.

Declaration
public void UnregisterRequestProcessor(string address)
Parameters
Type Name Description
System.String address

The address.

Explicit Interface Implementations

IContainer.AttachLink(ListenerConnection, ListenerSession, Link, Attach)

Declaration
bool IContainer.AttachLink(ListenerConnection connection, ListenerSession session, Link link, Attach attach)
Parameters
Type Name Description
ListenerConnection connection
ListenerSession session
Link link
Attach attach
Returns
Type Description
System.Boolean

IContainer.CreateLink(ListenerConnection, ListenerSession, Attach)

Declaration
Link IContainer.CreateLink(ListenerConnection connection, ListenerSession session, Attach attach)
Parameters
Type Name Description
ListenerConnection connection
ListenerSession session
Attach attach
Returns
Type Description
Link

IContainer.CreateMessage(ByteBuffer)

Declaration
Message IContainer.CreateMessage(ByteBuffer buffer)
Parameters
Type Name Description
ByteBuffer buffer
Returns
Type Description
Message

IContainer.ServiceCertificate

Declaration
X509Certificate2 IContainer.ServiceCertificate { get; }
Returns
Type Description
System.Security.Cryptography.X509Certificates.X509Certificate2

Implements

IContainerHost
IContainer
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX