IPWorks MQ 2020 Delphi Edition

Questions / Feedback?

AMQP Component

Properties   Methods   Events   Configuration Settings   Errors  

An easy-to-use AMQP 1.0 client implementation.




The AMQP component provides an easy-to-use AMQP 1.0 client implementation. The component supports both plaintext and TLS-enabled connections over TCP.


AMQP 1.0's transport protocol has three layers: an overarching connection between two containers, the sessions opened on that connection, and the links (between the containers' nodes) attached to those sessions.

The component implements all three layers of the AMQP 1.0 transport protocol, so the first step is to initiate the overall connection. Set the ContainerId property and call the Connect method, passing it the server's hostname and port number.

Once connected, the next step is to create at least one session, which can be accomplished by using the CreateSession method. The component allows creating any number of sessions, up to the limit specified by the MaxSessionCount configuration setting.

Connecting and Creating a Session

amqp1.ContainerId = "testClient";
amqp1.Connect("amqp.test-server.com", 5672);

After creating a session, the next step is to create one or more links (which are created in the context of a session) so that messages can be sent and/or received. Links are unidirectional, so each one has a sender on one end and a receiver on the other.

The component can function both as a sender node (by opening sender links) and as a receiver node (by opening receiver links). But keep in mind that, since the component is implemented as an AMQP 1.0 client, it must be the one to open links (said another way, the component cannot accept any link requests made by other peers).

As with sessions, the component allows creating any number of links for each session, up to the limit specified by the MaxLinkCountPerSession configuration setting.

Creating Sender Links

To create a sender link, call the CreateSenderLink method, passing it the name of an existing session, a unique name for the link, and (if necessary in your environment) the name of a target for the receiver to use to ensure messages are routed correctly.

The LinkReadyToSend event will fire when the newly created sender link is ready to send messages.

Creating a Sender Link

amqp1.OnLinkReadyToSend += (s, e) => {
  Console.WriteLine("Link '" + e.LinkName + "' is ready to send messages!");

amqp1.CreateSenderLink("TestSession", "TestSenderLink", "TestTarget");

Sending Messages

To send a message, the first step is to set the Message* properties to the desired values.

At minimum, the Value and ValueType properties must be set. All other properties are optional, though specifying a unique value for MessageId is recommended. (If the GenerateMessageId configuration setting is enabled, the component will generate one automatically when the message is sent.)

Once the Message* properties have be assigned as desired, call the SendMessage method, passing it the name of an existing sender link on which the message should be sent.

The MessageOut event will be fired when the message has been sent (and acknowledged, if Settled was set to false). The MessageOutcome event may also fire, if necessary, once the receiver reports the outcome of the message.

Refer to SendMessage, MessageOut, and MessageOutcome for more information.

Sending a Message

amqp1.OnMessageOut += (s, e) => {
  Console.WriteLine("Message with Id '" + e.MessageId + "' has been sent on link '" + e.LinkName + "'.");

amqp1.Message.MessageId = "TestMessageId";
amqp1.Message.Value = "Hello, world!";
amqp1.Message.ValueType = AMQPValueTypes.mvtString;


The ResetMessage method can be used to reset the Message* properties to their default values.

Sending Composite AMQP Data

The AMQP 1.0 protocol's data model includes the concept of "composite data". Composite data is comprised of one or more type-value pairs (including data structure types), plus a descriptor that describes what the overall data represents.

The component supports sending composite AMQP data in a message through the use of JSON with a well-defined schema. Refer to the SendMessage method's documentation for more information and examples.

Creating Receiver Links

Receiver links can operate in one of two receive modes: automatic, where the component will work to ensure that messages are received as soon as they are available; and fetch-based, where the component will only "fetch" a new message when explicitly instructed to.

The ReceiveMode property controls which receive mode newly-created receiver links will use; refer to its documentation for more information.

After ensuring that ReceiveMode is set as desired, call CreateReceiverLink, passing it the name of an existing session, a unique name for the link, and (if necessary in your environment) the name of a source for the sender to route the link creation request to.

Creating a Receiver Link

// Creating an automatic receiver link.
amqp1.ReceiveMode = AmqpReceiveModes.rmAutomatic;
amqp1.CreateReceiverLink("TestSession", "TestAutoReceiverLink", "TestSource1");

// Creating a fetch-based receiver link.
amqp1.ReceiveMode = AmqpReceiveModes.rmFetch;
amqp1.CreateReceiverLink("TestSession", "TestFetchReceiverLink", "TestSource2");

Receiving Messages

For receiver links created in automatic receive mode (the default), messages are received automatically.

For receiver links created in fetch-based mode, the component will attempt to "fetch" a message each time the FetchMessage method is called (optionally timing out after a time, if FetchTimeout is non-zero). When calling FetchMessage, pass it the name of a fetch-based receiver link.

Regardless of whether a messages is received automatically or fetched, any incoming message will cause the component to fire the MessageIn event and update the ReceivedMessage* properties.

When the MessageIn event fires, its State event parameter can be used to specify the outcome of the message, which the component will then transmit back to the sender (as well as self-report by firing the MessageOutcome event). Refer to MessageIn for more information.

Receiving a Message

// For automatic receiver links, only the event handler is necessary.
amqp1.OnMessageIn += (s, e) => {
  Console.WriteLine("Message with Id '" + e.MessageId + "' has been received on link '" + e.LinkName + "'. Value:");

  // The message state is already set to the "Accepted" outcome by default, but we'll set it again
  // for the purpose of this example.
  e.State = 0; // 0 = Accepted.

// For fetch-based links, it's also necessary to call FetchMessage(). It is recommended that the
// FetchTimeout property be set to a non-zero value (60 seconds is the default) so that the fetch
// request will eventually time out if the sender doesn't have any messages available to deliver.
amqp1.FetchTimeout = 60;

Property List

The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

AuthSchemeThe authentication scheme to use when connecting.
ConnectedTriggers a connection or disconnection.
ContainerIdThe container Id the component should advertise when connecting.
FetchTimeoutHow long the component should wait for a message to be received after FetchMessage is called.
FirewallA set of properties related to firewall access.
IdleTimeoutThe maximum period of inactivity the component will allow before disconnecting.
IncomingMessagesCollection of incoming messages which have not been fully settled.
LinksCollection of active links.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the component binds.
MessageThe message to send.
OutgoingMessagesCollection of outgoing messages which have not been fully settled.
PasswordA password to use for SASL authentication.
ReadyToSendIndicates whether the component is ready to send data.
ReceivedMessageThe last message received.
ReceiveModeControls what mode new receiver links are created with.
RemoteHostThe address of the remote host. Domain names are resolved to IP addresses.
RemotePortThe port of the AQMP server (default is 5672). The default port for SSL is 5671.
SessionsCollection of active sessions.
SSLAcceptServerCertEncodedThe certificate (PEM/base64 encoded).
SSLCertEncodedThe certificate (PEM/base64 encoded).
SSLCertStoreThe name of the certificate store for the client certificate.
SSLCertStorePasswordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
SSLCertStoreTypeThe type of certificate store for this certificate.
SSLCertSubjectThe subject of the certificate used for client authentication.
SSLEnabledWhether TLS/SSL is enabled.
SSLServerCertEncodedThe certificate (PEM/base64 encoded).
TimeoutA timeout for the component.
UserA username to use for SASL authentication.

Method List

The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

CloseLinkCloses a link.
CloseSessionCloses a session.
ConfigSets or retrieves a configuration setting.
ConnectConnects to a remote host.
CreateReceiverLinkCreates a new receiver link with the given name on the specified session.
CreateSenderLinkCreates a new sender link with the given name on the specified session.
CreateSessionCreates a new session with the given name.
DisconnectDisconnects from the remote host.
DoEventsProcesses events from the internal message queue.
FetchMessageFetches a single message over the specified receiver link.
InterruptInterrupts the current action.
ResetReset the component.
ResetMessageResets the Message properties.
SendMessageSends a message on the specified link.

Event List

The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

ConnectedFired immediately after a connection completes (or fails).
ConnectionStatusFired to indicate changes in connection state.
DisconnectedFired when a connection is closed.
ErrorInformation about errors during data delivery.
LinkReadyToSendFires when a sender link is ready to send messages.
LogFires once for each log message.
MessageInFires when the component receives a message.
MessageOutFires when the component sends a message.
MessageOutcomeFires when a message's outcome is available.
SSLServerAuthenticationFired after the server presents its certificate to the client.
SSLStatusShows the progress of the secure connection.

Configuration Settings

The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

AuthorizationIdentityThe value to use as the authorization identity when SASL authentication is used.
DefaultCreditThe amount of credit to create new receiver links with.
DefaultCreditThresholdThe credit threshold to create new receiver links with.
DefaultIncomingWindowThe incoming window size to create new sessions with.
DefaultOutgoingWindowThe outgoing window size to create new sessions with.
DefaultSenderSettleModeThe sender settle mode to create new links with.
GenerateMessageIdWhether a unique message Id should be automatically generated when sending a message.
LogLevelThe level of detail that is logged.
MaxFrameSizeThe maximum frame size.
MaxLinkCountPerSessionThe maximum number of links to restrict new sessions to.
MaxMessageSizeThe maximum message size to restrict new links to.
MaxSessionCountThe maximum number of sessions.
ModifiedDeliveryFailedWhether the sender should treat this transfer as an unsuccessful delivery attempt.
ModifiedMessageAnnotationsThe message annotations that the sender should merge into those already on the message.
ModifiedUndeliverableHereWhether the receiver has indicated that the sender should not attempt to redeliver the message.
ProtocolVersionThe AMQP protocol version to conform to.
RejectErrorConditionThe error condition included with a 'Rejected' delivery outcome.
RejectErrorDescriptionThe error description included with a 'Rejected' delivery outcome.
SenderSettleMode[LinkName]Retrieves the negotiated sender settle mode for the specified link.
SimplifiedJSONFormatWhether to output simplified JSON where possible.
CloseStreamAfterTransferIf true, the component will close the upload or download stream after the transfer.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the component whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe port in the local host where the component binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
ProxyExceptionsListA semicolon separated list of hosts and IPs to bypass when using a proxy.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
TcpNoDelayWhether or not to delay when sending packets.
UseIPv6Whether to use IPv6.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedProtocolReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks MQ 2020 Delphi Edition - Version 20.0 [Build 8155]