Skip to main content
Version: 0.0.1

RabbitMQ Consumer Transport

Consume Telegram updates from a RabbitMQ queue.

Configuration

application.yml:

easygram:
token: ${BOT_TOKEN}
transport: RABBIT_CONSUMER
rabbit-consumer:
queue: easygram-updates
exchange: easygram-exchange
routing-key: easygram.updates
create-if-absent: true

spring:
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
virtual-host: /

Configuration Options

PropertyRequiredDefaultDescription
easygram.rabbit-consumer.queueYesRabbitMQ queue to consume from
easygram.rabbit-consumer.exchangeNoeasygram-exchangeExchange to bind queue to
easygram.rabbit-consumer.routing-keyNoeasygram.updatesRouting key for the binding
easygram.rabbit-consumer.create-if-absentNotrueAuto-create exchange, queue, and binding

Docker Deployment

docker-compose.yml:

version: '3.8'

services:
rabbitmq:
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672" # Management UI
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest

bot:
build: .
environment:
TELEGRAM_BOT_TRANSPORT: RABBIT_CONSUMER
SPRING_RABBITMQ_HOST: rabbitmq
depends_on:
- rabbitmq
restart: unless-stopped

Example

@BotController
public class RabbitBotHandler {
@BotCommand("/start")
public String onStart() {
return "Bot connected to RabbitMQ!";
}
}

See RabbitMQ Documentation for advanced queue setup.


All transports configured! Next: Advanced Features