AMQP (Advanced Message Queueing Protocol) is an open protocol for fast asynchronous transfer of messages between applications with minimal delay.
To maintain connection with external services via this protocol the RabbitMQ message broker is used. Message brokers create a two-way connection with each system of applications. This connection is used to transmit messages, the messages are routed to corresponding destination points.
AMQP is based on three concepts:
Message is a unit of transmitted data, its main part (content) is not interpreted by the server in any way. Structured headings may be attached to a message.
Exchange is where the messages are directed to. However messages are not stored in the exchange.
Queue is where the messages are stored until taken by a consumer. A consumer always takes the messages from one or several queues.
Processing sequence
All messages, generated by the producer, are first accepted in the exchange.
Here they are distributed between queues. Bindings are used to send messages to corresponding queues.
Sent messages remain in this queue until the consumer connects and receives the message.
The consumer receives the message.
A delivery verification mechanism is implemented in AMQP: a message is not removed from a queue until receipt confirmation is received from the consumer.
In case of negative response, the message may be re-sent or removed depending on producer's configuration settings during sending of the message.
Connecting to a queue
For integration and sending of messages through the RabbitMQ broker, set up a queue in the system:
Navigate to External Queues → RabbitMQ providers.
Click Create and fill in the required fields.
Click Save or Save and Exit.
Field
Mandatory
Description
Name
Y
Specify a name for created message queue. This queue name will be used to send messages from the API.
Host name
Y
Enter RabbitMQ host name to connect to, in the format example.ru.
Port
Y
Specify the server connection port.
Virtual host
N
Specify the host designated in the RabbitMQ server settings.
Connection time out
N
Set the RabbitMQ server connection time out.
Username
Y
Specify user login for RabbitMQ server connection.
Password
Y
Specify user password for RabbitMQ server connection.
To send messages to the queue, create a message processing server script using the SimpleExternalRabbitMQ class.