---
title: Python message queues
source: https://docs.newrelic.com/docs/apm/agents/python-agent/supported-features/python-message-queues
---

The Python agent supports the [Pika RabbitMQ client library](https://pypi.python.org/pypi/pika), [Kafka Python client library](https://pypi.python.org/pypi/kafka-python), and the [Confluent Kafka client library](https://pypi.org/project/confluent-kafka/) giving you visibility into the performance of your message processing, for both incoming and outgoing messages.

The New Relic UI will show transactions initiated via message receipt (subscribe/consume messages) as **Message** background tasks. Message creation also appears in transaction traces.

## Requirements

| **Message Queue** | **Python agent version required** |
| ----------------- | --------------------------------- |
| Pika RabbitMQ     | 2.88.0.72                         |
| Kafka Python      | 8.2.0.181                         |
| Confluent Kafka   | 8.2.0.181                         |

For more information, see [the release notes](https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes).

> #### ⚠️ CAUTION
>
> RabbitMQ message tasks are not started for consumers using [TornadoConnection](https://pika.readthedocs.io/en/latest/modules/adapters/tornado.html#pika.adapters.tornado_connection.TornadoConnection).

> #### ⚠️ CAUTION
>
> When consuming messages via Kafka, transactions are reported for each message as it is consumed by the consumer. Transactions will not be reported for bulk consumption operations where multiple messages are consumed at once.

## Performance improvements with background tasks [#background]

One way to increase responsiveness of web applications is to delegate work to background processes. Message queues are commonly used for this inter-process communication.

In the context of message queuing systems, applications typically interact with message brokers to send and receive messages. In the case of RabbitMQ Pika, this client library allows Python applications to interface with message brokers that implement the Advanced Message Queueing Protocol (AMQP) 0.9 or higher.

The Python agent shows messages sent and received using the client libraries. With this visibility, you can see details including:

-   Number of messages produced by your app
-   Time your app spends publishing/producing messages
-   Time your app spends processing/consuming messages

[APM](#view-queue) conveniently groups and reports operations that interact with queues. By analyzing this information, you can more easily identify bottlenecks and areas for performance improvement in your message passing architecture.

## Supported Metrics

| **Message Queue**     | **Pika RabbitMQ**          | **Kafka Python**              | **Confluent Kafka**           |
| --------------------- | -------------------------- | ----------------------------- | ----------------------------- |
| **Publish a Message** | Yes--Referred to as `Put`  | Yes--Referred to as `Produce` | Yes--Referred to as `Produce` |
| **Receive a Message** | Yes--Referred to as `Take` | Yes--Referred to as `Consume` | Yes--Referred to as `Consume` |
| **Serialization**     | No                         | Yes                           | Yes                           |
| **Deserialization**   | No                         | No                            | Yes                           |
| **Heartbeat**         | No                         | Yes                           | No                            |

## View in New Relic UI [#view-queue]

Queue operations appear on APM's [**Transactions** page](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/transactions-dashboard) for the selected app.

The `Put` (publish a message) and `Take` (receive a message) metrics appear in the **Breakdown table** and are categorized as `MessageBroker` metrics for RabbitMQ. Here is an example:

![New Relic for Python rabbitmq task](https://docs.newrelic.com/images/apm_screenshot-crop_rabbitmq-transaction-task.webp "screen-rabbitmq-transaction.png")

**[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities) > APM & services > (select an app) > Monitor > Transactions > (select a transaction):** The transaction’s **Breakdown table** categorizes queue operations as `MessageBroker` metrics for RabbitMQ and labels them as `Put` (publish a message) or `Take` (receive a message).

[Transaction traces](https://docs.newrelic.com/docs/apm/transactions/transaction-traces/transaction-traces) also provide additional details for messages.

> #### 💡 TIP
>
> You can [select transaction traces](https://docs.newrelic.com/docs/apm/transactions/transaction-traces/viewing-transaction-traces) from the app's **Summary** or **Transactions** pages in APM.

The [**Transaction trace summary** page](https://docs.newrelic.com/docs/apm/transactions/transaction-traces/transaction-traces-trace-details-page) may show `Put` and `Take` operations for RabbitMQ in the **Slowest components** section. For example:

![New Relic for Python rabbitmq transaction trace summary](https://docs.newrelic.com/images/apm_screenshot-crop_rabbit-mq-transaction-trace-summary.webp "screen-rabbitmq-trace-slowest.png")

**[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities) > APM & services > (select an app) > (select a transaction trace):** In this example, the selected transaction trace's **Summary** shows RabbitMQ operations in the colored bar chart. The **Slowest components** section also lists the RabbitMQ `Put` and `Take` results.
