florianajir/rabbitmq-sql-bundle

RabbitMQ to sql consumer, using doctrine/dbal and php-amqplib/rabbitmq-bundle

v1.0.0 2016-05-03 21:44 UTC

This package is auto-updated.

Last update: 2024-04-04 15:08:48 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Code Coverage Scrutinizer Code Quality

About

The RabbitMqSqlBundle is a symfony worker to provide rabbitmq message persistence for your application using the php-amqplib/rabbitmq-bundle and doctrine/dbal libraries.

You just need to configure the mapping in yml and execute a command, a simple and scalable rabbitmq to sql consumer to persist your entities:

php app/console rabbitmq:consumer -w sql

Features

  • mapping yml config (doctrine like)
  • Insert records
  • Update records
  • Relational records : oneToOne, oneToMany, manyToOne, manyToMany
  • Update, Delete relations
  • Foreign keys support

Examples

Following example shows you the consuming process to persist in database a simple subscriber from an asynchronous message data.

RabbitMQ incoming message data:

{
  "name" : "Rogger Rabbit",
  "email" : "subscriber@acme.corp",
  "Groups": [ { "slug": "subscriber" } ]
}

SQL requests output:

INSERT INTO `members` (`name`, `email`) VALUES ("Rogger Rabbit", "subscriber@acme.corp");
INSERT INTO `member_group` (`member_id`, `group_id`) VALUES (3, 2);

Take more inspiration from Examples documentation

License

This application is under the MIT license. See the complete license in this file :

Resources/meta/LICENSE

Installation

For Symfony Framework >= 2.3

Require the worker and its dependencies with composer:

$ composer require florianajir/rabbitmq-sql-worker

Register this bundles:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
        new FlorianAjir\RabbitMqSqlBundle\FlorianAjirRabbitMqSqlBundle(),
    );
}

Configuration

You have to configure the rabbitmq and the database and define message structures and database mapping.

Enjoy !