Skip to content

vfunin/rabbitmq-consumer

Repository files navigation

Go RabbitMQ Consumer


The application reads messages from the queue and saves them to the database.

Supported databases

  • PostgreSQL
  • MySQL

Building the source

make build

or for build with flags

make build-flags

Local environment

make all

Using the app

  • Create a table in your database:

PostgreSQL:

CREATE TABLE public.messages (
  id bigserial PRIMARY KEY,
  correlation_id text,
  created_at timestamptz default CURRENT_TIMESTAMP,
  message text
);


CREATE INDEX messages_correlation_id_index
    ON messages (correlation_id);

MySQL

CREATE TABLE messages
(
    id             int auto_increment primary key,
    correlation_id varchar(255)                        null,
    created_at     timestamp default CURRENT_TIMESTAMP not null,
    message        text                                null
);

CREATE INDEX messages_correlation_id_index
    ON messages (correlation_id);

  • Change config.yaml
  • Run the app:
./rabbitmq-consumer -config config.yaml

Development plan

  • Base functionality
  • Add auto reconnect to DB
  • Change structure
  • Add Sentry support
  • Add tests
  • Add optional saving headers and properties