Skip to content

XpressAI/xai-rabbitmq

Repository files navigation

Component LibrariesProject Templates
DocsInstallTutorialsDeveloper GuidesContributeBlogDiscord

Xircuits Component Library to interface with RabbitMQ! Build robust messaging and queuing workflows.


Xircuits Component Library for RabbitMQ

This library enables Xircuits to integrate with RabbitMQ for building messaging-based workflows. It provides components to connect, publish, consume, and manage messages in RabbitMQ queues efficiently.

Table of Contents

Preview

The Example:

rabbitmq_sample

The Result:

rabbitmq_sample_result

Prerequisites

Before you begin, you will need the following:

  1. Python3.9+.
  2. Xircuits.
  3. RabbitMQ

Main Xircuits Components

RabbitMQConnect Component:

Connects to a RabbitMQ broker with optional credentials (username, password). Initializes the RabbitMQ client and channel for message operations.

RabbitMQConnect

RabbitMQPublish Component:

Publishes a message to a specified queue, exchange, or routing key. If the queue does not exist, it is created automatically.

RabbitMQPublish

RabbitMQConsume Component:

Consumes messages from a queue and triggers a connected component (on_message) for processing. Acknowledges messages automatically after processing.

Try The Examples

We have provided an example workflow to help you get started with the RabbitMQ component library. Give it a try and see how you can create custom RabbitMQ components for your applications.

RabbitMQ Example

This example demonstrates how to connect to a RabbitMQ server, consume messages from a queue, modify them by appending extra text, and publish the modified messages to another queue. It also prints the processed messages for verification.

Installation

To use this component library, ensure that you have an existing Xircuits setup. You can then install the RabbitMQ library using the component library interface, or through the CLI using:

xircuits install rabbitmq

You can also do it manually by cloning and installing it:

# base Xircuits directory
git clone https://github.com/XpressAI/xai-rabbitmq xai_components/xai_rabbitmq
pip install -r xai_components/xai_rabbitmq/requirements.txt

RabbitMQ Local Setup

To set up RabbitMQ locally for testing:

  1. Install RabbitMQ:

    • On Ubuntu/Debian:
      sudo apt update && sudo apt install rabbitmq-server -y
    • On Windows: Download and install RabbitMQ and Erlang from the official RabbitMQ website.
  2. Start RabbitMQ:

    • On Linux:
      sudo systemctl start rabbitmq-server
      sudo systemctl enable rabbitmq-server  # Optional: Auto-start on boot
    • On Windows: Start RabbitMQ as a service via services.msc or the command prompt.
  3. Access RabbitMQ:

  4. Run the Xircuits Example:

    • Create the testing and testing_reply queues in RabbitMQ.
    • Execute the Xircuits example to consume and process messages.

About

Xircuits component library for RabbitMQ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages