Giter Club home page Giter Club logo

psr-container-messenger's Introduction

No Maintenance Intended

Thank you so much for being interested in this project! Open Source is rewarding, but it can also be exhausting. Therefor this code is provided as-is, and is currently not actively maintained. We invite you to peruse the code and even use it in your next project, provided you follow the included license!

No guarantee of support for the code is provided, and there is no promise that pull requests will be reviewed or merged. It’s open source, so forking is allowed; just be sure to give credit where it’s due!


PSR-11 Container compatible Symfony Messenger message bus and queue.

This packages brings message buses to your PSR-11 container based project. It's a bundle of factories to make life easier for you. The real work is done by Symfony Messenger.

It comes with pre-configured command, event and query buses for your convenience. Or don't use them if you want to create your own. Transports can be used to queue your messages or send and receive them to/from 3rd parties.

Installation

composer require xtreamwayz/psr-container-messenger

Documentation

All project documentation is located in the ./docs folder. If you would like to contribute to the documentation, please submit a pull request. You can read the docs online: https://xtreamwayz.github.io/psr-container-messenger/

Contributing

BEFORE you start work on a feature or fix, please read & follow the contributing guidelines to help avoid any wasted or duplicate effort.

Copyright and license

Code released under the MIT License. Documentation distributed under CC BY 4.0.

psr-container-messenger's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar geerteltink avatar m-steinmann avatar mateuszsip avatar notdefine avatar renovate[bot] avatar tobias-trozowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

psr-container-messenger's Issues

Remove default middleware config

Remove the middleware config from the standard configuration as it does not work when adding more middleware. The order can't be specified correctly.

The configuration should be move to example config files which users can copy and adjust.

feat: Add BusName Stamp Middleware Factory

Is your feature request related to a problem? Please describe.
In symfony/messenger at version 4.3 a new middleware called AddBusNameStampMiddleware was added.
You need to add this middleware to your bus to handle async messanges properly.
The middleware needs bus name as constructor dependency.

Describe the solution you'd like
Adding a static factory for the AddBusNameStampMiddleware.

bug: When dispatch to Rabbimq failing, Messages get lost

We found a constelation, when using RabbitMQ with the transport option

    'messenger' => [
        'transports' => [
             'options' => ['confirm_timeout' => 1]
        ]
]

no retry is made. So we add a middleware to retry this dispatch. This middleware must be added to the command bus configuration.

<?php

declare(strict_types=1);

namespace Mehrkanal\Messenger\Middleware;

use AMQPQueueException;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\TransportException;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Throwable;

final class ConfirmTimeoutMiddleware implements MiddlewareInterface
{
    public const MAX_PUBLISH_TRIES = 5;

    public function __construct(private LoggerInterface $logger)
    {
    }

    public function handle(Envelope $envelope, StackInterface $stack): Envelope
    {
        for ($try = 0; $try < self::MAX_PUBLISH_TRIES; $try++) {
            try {
                return $stack->next()
                    ->handle($envelope, $stack);
            } catch (AMQPQueueException|TransportException $exception) {
                $this->logger->warning(
                    'RabbitMQ publishing retry.',
                    [
                        'class' => self::class,
                        'exception_class' => $exception::class,
                        'exception_message' => $exception->getMessage(),
                        'exception_trace' => $exception->getTrace(),
                        'envelop' => $envelope,
                        'try' => $try,
                    ]
                );
            } catch (Throwable $throwable) {
                $this->logger->critical('RabbitMQ publishing exception.', [
                    'class' => self::class,
                    'envelop' => $envelope,
                    'exception_class' => $throwable::class,
                    'exception_message' => $throwable->getMessage(),
                    'exception_trace' => $throwable->getTrace(),
                ]);
                throw new RuntimeException('Publishing failed', previous: $throwable);
            }
        }
        $this->logger->critical('RabbitMQ publishing failed.', [
            'class' => self::class,
            'envelop' => $envelope,
        ]);
        throw new RuntimeException('Publishing failed');
    }
}

Since this project has no recent activity, and there are no responses to Merge Requests I place my knowlege her. Because we had some trouble with missing Messages.

greetings Thomas

feat: Config support for TransportFactory

Is your feature request related to a problem? Please describe.
I would like to create a queue with additional config parameters e.g. with argument 'x-queue-type' => 'quorum',.
In the current TransportFactory I can only declare the dsn.

Describe the solution you'd like
I want the possibility to create a transport with a config alias instead of the dsn. The config alias should reference to an config array with a dsn and additional arguments.

Question: Service Manager is required but not fully utilized

Is the intention of this project to move laminas/laminas-service-manager from "required" to "require-dev"?

Either:

  • This should be the case, so that other PSR-11 containers can use the provided factories (as I believe would currently be the case).
  • Or the third argument provided to __invoke() on the factories: string $requestedName, should be used in place of class names where possible, to allow factories to be reused.

Add logging option

The logging middleware is removed in 4.3. Logging can now be added to the transports and message handling middleware.

feat: use psr/event-dispatcher

Is your feature request related to a problem? Please describe.

I can't select my own event dispatcher.

Describe the solution you'd like

Use the psr/event-dispatcher instead of hardcoding the Symfony dispatcher.

Describe alternatives you've considered

n/a

Additional context

n/a

bug: PHP-DI doesn't support factories with magic methods

Describe the bug
If someone uses mezzio + PHP-DI, they will receive an error MessageBusFactory::messenger.command.bus() is not a callable. A __call() or __callStatic() method exists but magic methods are not supported.

PHP-DI uses PHP-DI/Invoker.

To Reproduce
Steps to reproduce the behavior:

  1. Create project of Mezzio with PHP-DI container
  2. Add current library into the project
  3. Try to dispatch a command
  4. See error

Version of the xtreamwayz/psr-container-messenger library
2.5.0

Expected behavior
Command successfully dispatched.

How to fix it for yourself
Use custom configuration entries for the factories or custom ConfigProvider

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance

  • Check this box to trigger a request for Renovate to run again on this repository

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.