Coder Social home page Coder Social logo

handcraftedinthealps / redistransportbundle Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 5.0 52 KB

[DEPRECATED] Now part of symfony/messenger since 4.3. Use that implementation instead!

License: MIT License

PHP 100.00%
symfony symfony-bundle symfony-messenger redis message-bus php

redistransportbundle's Introduction

RedisTransportBundle ⛰

GitHub license GitHub tag (latest SemVer) CircleCI

A symfony messenger transport implementation for redis streams.

NOTE: Most of the logic has moved to the Core Symfony Messenger component in 4.3. So this bundle is not longer a requirement to use messenger with redis streams. You can now use the redis:// instead of redis-stream:// and remove this bundle from your requirements.

Requirements

  • PHP: ^7.1
    • Redis Extension: ^4.2
  • Redis Server: ^5.0

Symfony compatibility

Symfony Messenger Version Bundle Version
4.2 1.0
4.3 1.1

When upgrading to symfony 4.3 you should replace this bundle with the symfony redis:// transport and remove the bundle from your requirements.

Installation

You need composer to install this bundle to your symfony application.

composer require handcraftedinthealps/redis-transport-bundle

Configuration

Symfony

When using the symfony/framework-bundle you can configure the following:

# config/packages/framework.yaml
framework:
    messenger:
        routing:
            'HandcraftedInTheAlps\Bundle\RedisTransportBundle\Message\DomainEventMessage':
                senders: ['redis_stream']
        transports:
            redis_stream: 'redis-stream://127.0.0.1:6379/my_stream/my_group/my_consumer'

You can then send a DomainEventMessage or your custom Message over the redis stream:

use HandcraftedInTheAlps\Bundle\RedisTransportBundle\Message\DomainEventMessage;

$this->messageBus->dispatch(
    new DomainEventMessage(
        'mountain.modified',    // the custom event action
        'mountain',             // the model which has been changed
        '1',                    // the model id or uuid
        [                       // the model payload
            'id' => '1',
            'name' => 'Piz Buin',
            'height' => 3312,
        ]
    )
);

And you can consume the messages with:

bin/console messenger:consume-messages redis_stream

Have also a look at the messenger component documentation and messenger usage documentation.

Commands

Messages in streams won't be removed by default. Therefor this bundle provides a command:

bin/console redis-transport:trim <redis-dsn> --maxlen 1000

redistransportbundle's People

Contributors

alexander-schranz avatar chirimoya avatar luca-rath avatar martinlagler avatar niklasnatter avatar wachterjohannes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

redistransportbundle's Issues

Document how to create a stream/group

redis-cli

xgroup CREATE my_stream my_group $

xgroup CREATE my_stream my_group $ MKSTREAM

And for debugging communication:

xread COUNT 2 BLOCK 0 GROUPS my_group STREAMS my_stream $

Implementing Testcases

  • Implement TransportFactory Tests
  • Implement TransportSender Tests
  • Implement TransportReceiver Tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.