Skip to content

amqp_collector

qoa4ml.collector.amqp_collector

Classes

AmqpCollector

AmqpCollector handles the connection to an AMQP server for collecting and processing messages.

Parameters:

Name Type Description Default
configuration
AMQPCollectorConfig

Configuration settings for connecting to the AMQP server.

required
host_object
Optional[HostObject]

An optional HostObject to process incoming messages, default is None.

None

Attributes:

Name Type Description
host_object Optional[HostObject]

The host object responsible for processing messages.

exchange_name str

The name of the exchange to connect to.

exchange_type str

The type of the exchange (e.g., 'direct', 'topic').

in_routing_key str

The routing key for incoming messages.

in_connection BlockingConnection

The connection to the RabbitMQ server.

in_channel Channel

The channel for communication with RabbitMQ.

queue DeclareOk

The queue to receive prediction responses.

queue_name str

The name of the queue.

Methods:

Name Description
on_request

Process incoming request messages.

start_collecting

Start collecting messages from the queue.

stop

Stop collecting messages and close the connection.

get_queue

Get the name of the queue.

Functions
__init__(configuration, host_object=None)

Initialize an instance of AmqpCollector.

Parameters:

Name Type Description Default
configuration AMQPCollectorConfig

Configuration settings for connecting to the AMQP server.

required
host_object Optional[HostObject]

An optional HostObject to process incoming messages, default is None.

None
get_queue()

Get the name of the queue.

Returns:

Type Description
str

The name of the queue.

on_request(ch, method, props, body)

Process incoming request messages.

Parameters:

Name Type Description Default
ch Channel

The channel object for the communication.

required
method Deliver

The method frame object containing delivery parameters.

required
props BasicProperties

The properties frame object containing message properties.

required
body bytes

The message body sent from the producer.

required
Notes

If host_object is provided, it will handle message processing. Otherwise, the raw message will be logged.

start_collecting()

Start collecting messages from the queue.

Notes

This method starts the RabbitMQ consumer to collect messages from the queue and process them. The method will block and run indefinitely until stop is called.

stop()

Stop collecting messages and close the connection.

Notes

This method stops the consumer from collecting messages and closes the channel.