定制 sulu/messenger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sulu/messenger

最新稳定版本:0.2.10

Composer 安装命令:

composer require sulu/messenger

包简介

This library provides the stamps, middlewares and the sulu message bus.

README 文档

README

Official Sulu Bundle Badge

GitHub license GitHub tag (latest SemVer) Test workflow status Sulu compatibility


This library provides the stamps and middlewares which configures the sulu message bus. It can be used independently in any symfony installation.

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Open a command console, enter your project directory and execute:

composer require sulu/messenger

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    Sulu\Messenger\Infrastructure\Symfony\HttpKernel\SuluMessengerBundle::class => ['all' => true],
];

Middlewares

UnpackExceptionMiddleware

The UnpackExceptionMiddleware will unpack the HandlerFailedException which is created by the Symfony HandleMessageMiddleware. This way we make sure that the real exception is thrown out by this message bus, and a controller can catch or convert it to a specific http status code. This middleware is always activated in the sulu message bus.

LockMiddleware

The LockMiddleware will allow to lock specific resources by a given key. This is commonly used to prevent concurrent access to the same resource and avoid race conditions. The locking can be activated and controlled via the LockStamp which supports the same parameters as the Symfony LockFactory to create the Lock.

use Sulu\Messenger\Infrastructure\Symfony\Messenger\LockMiddleware\LockStamp;

$this->handle(new Envelope(new YourMessage(), [new LockStamp('lock-key')]));

# set ttl and autorelease
$this->handle(new Envelope(new YourMessage(), [new LockStamp('lock-key', 300.0, true)]));

# multiple locks possible all locks need to be acquired before processing the message
$this->handle(new Envelope(new YourMessage(), [new LockStamp('lock-key-1'), new LockStamp('lock-key-2')]));

DoctrineFlushMiddleware

The DoctrineFlushMiddleware is a Middleware which let us flush the Doctrine EntityManager by an opt-in flag via the EnableFlushStamp. It can be used this way:

use Sulu\Messenger\Infrastructure\Symfony\Messenger\FlushMiddleware\EnableFlushStamp;

$this->handle(new Envelope(new YourMessage(), [new EnableFlushStamp()]));

This middleware is always activated in the sulu message bus.

统计信息

  • 总下载量: 72.33k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-10