Git Product home page Git Product logo

sonatanotificationbundle's Introduction

SonataNotificationBundle

Symfony SonataNotificationBundle

Latest Stable Version Latest Unstable Version Psalm Type Coverage License

Total Downloads Monthly Downloads Daily Downloads

Branch Github Actions Code Coverage Documentation
3.x Test Coverage Status Documentation Status
4.x Test Coverage Status Documentation Status

WARNING: This repository is abandoned

There is no active support on it.

Feel free to ask if you want to help to keep this project up to date.

Documentation

Check out the documentation on the official website.

Support

For general support and questions, please use StackOverflow.

If you think you found a bug or you have a feature idea to propose, feel free to open an issue after looking at the contributing guide.

License

This package is available under the MIT license.

sonatanotificationbundle's People

Contributors

bangpound avatar bdejacobet avatar bladrak avatar core23 avatar covex-nn avatar franmomu avatar greg0ire avatar gremo avatar havvg avatar jordisala1991 avatar kix avatar kunicmarko20 avatar lkazus avatar makasim avatar marcusorjames avatar oskarstark avatar petk avatar phansys avatar pulse00 avatar pulzarraider avatar qsomazzi avatar rande avatar sensi avatar shiroko avatar sonataci avatar soullivaneuh avatar sylvaindeloux avatar vincentlanglet avatar vyshkant avatar wbloszyk 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonatanotificationbundle's Issues

notification:start randomly caps cpu at 100%

Environment

AWS EC2 small instances, running amazon linux and php 7.1.
RabbitMQ installed locally.
RabbitMQ as well as sonata notifications are set up to auto restart should they go down via supervisor.

Sonata packages

$ composer show --latest 'sonata-project/*'
`sonata-project/admin-bundle              3.31.0             The missing Symfony Admin Generator
sonata-project/block-bundle              3.11.0             Symfony SonataBlockBundle
sonata-project/cache                     2.0.1              Cache library
sonata-project/classification-bundle     3.x-dev 0f3f55f    Symfony SonataClassificationBundle
sonata-project/core-bundle               3.9.0              Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1              Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2              Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.4.1              Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.4.0              Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0              Lightweight Exporter library
sonata-project/notification-bundle       3.3.0              Symfony SonataNotificationBundle
sonata-project/user-bundle               dev-master 7a210f8 Symfony SonataUserBundle
`

Symfony packages

$ composer show --latest 'symfony/*'
`symfony/monolog-bundle                   v3.1.2             Symfony MonologBundle
symfony/phpunit-bridge                   v3.4.3             Symfony PHPUnit Bridge
symfony/polyfill-apcu                    v1.6.0             Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu                v1.6.0             Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring                v1.6.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                   v1.6.0             Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                   v1.6.0             Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                    v1.6.0             Symfony utilities for portability of PHP codes
symfony/security-acl                     v3.0.1             Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle               v2.6.7             Symfony SwiftmailerBundle
symfony/symfony                          v3.4.3             The Symfony PHP framework
`

PHP version

$ php -v
`PHP 7.1.7 (cli) (built: Sep 14 2017 15:47:38) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.7, Copyright (c) 1999-2017, by Zend Technologies`

Subject

So since updating to version 3.3.0 of the message bundle I have that problem that it maxes out my CPU at 100% randomly.
Apparently something at the startup of a new iteration cycle goes bad causing it to cap at 100% and stay there.
Sadly it will not generate logs when it does this so I'm having a hard time pinpointing the issue.
(The log below is the only thing that was in my rotated log)

Steps to reproduce

Unknown, maybe the connection refusal causes it somehow?

Expected results

That it starts normally each time without causing the CPU to go to 100% and stay there till you kill the php process running sonata:notification:start

Actual results

[Mon, 05 Feb 2018 22:48:30 +0000] Retrieving backend ...22:48:30 ERROR     [console] Error thrown while running command "sonata:notification:start --env=prod --iteration=250". Message: "stream_socket_client(): unable to connect to tcp://localhost:5672 (Connection refused)" ["error" => ErrorException { โ€ฆ},"command" => "sonata:notification:start --env=prod --iteration=250","message" => "stream_socket_client(): unable to connect to tcp://localhost:5672 (Connection refused)"] []

In StreamIO.php line 138:

  stream_socket_client(): unable to connect to tcp://localhost:5672 (Connecti
  on refused)


sonata:notification:start [-i|--iteration [ITERATION]] [--type [TYPE]] [-d|--show-details [SHOW-DETAILS]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

I've also got a new relic transaction case of such a long running action:

Custom	Enqueue\AmqpLib\AmqpConsumer::receiveBasicGet	230	989,000 ms	77%
Custom	Enqueue\AmqpLib\AmqpConsumer::receive	230	283,000 ms	22%
Custom	Sonata\NotificationBundle\Iterator\AMQPMessageIterator::next	230	6,350 ms	0%
Custom	PhpAmqpLib\Wire\IO\StreamIO::select	125	5,380 ms	0%
Custom	Sonata\NotificationBundle\Command\ConsumerHandlerCommand::execute	1	1,330 ms	0%
Custom	PhpAmqpLib\Channel\AbstractChannel::wait	132	181 ms	0%
Total time			1,280,000 ms	100%

Admin class not found fatal error

This bundle now depends on Admin Bundle to be installed.

PHP Fatal error: Class 'Sonata\AdminBundle\Admin\Admin' not found in /Users/gabriel/Zend/workspaces/PM2/PMAppMIBundle/vendor/sonata-project/notification-bundle/Sonata/NotificationBundle/Admin/MessageAdmin.php on line 21

@rande, Can this dependency be removed as it breaks the usefulness of the notification bundle.

Issue when running sonata:notification:start

Environment

dev

Sonata packages

SonataNotificationBundle

$ composer show --latest 'sonata-project/*'

sonata-project/admin-bundle              3.40.2 = 3.40.2 The missing Symfony Admin Generator
sonata-project/block-bundle              3.12.1 = 3.12.1 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  = 2.0.1  Cache library
sonata-project/classification-bundle     3.7.1  = 3.7.1  Symfony SonataClassificationBundle
sonata-project/core-bundle               3.11.2 = 3.11.2 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.4.0  = 2.4.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.1.0  = 1.1.0  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.6.2  ! 3.6.3  Symfony Sonata / Integrate Doctrine ORM into the SonataAdm...
sonata-project/easy-extends-bundle       2.5.0  = 2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.9.1  = 1.9.1  Lightweight Exporter library
sonata-project/formatter-bundle          3.5.0  ~ 4.1.2  Symfony SonataFormatterBundle
sonata-project/media-bundle              3.16.2 = 3.16.2 Symfony SonataMediaBundle
sonata-project/notification-bundle       3.5.1  = 3.5.1  Symfony SonataNotificationBundle
sonata-project/notification-orm-pack     1.0.0  = 1.0.0  A pack for SonataNotificationBundle with ORM support

Symfony packages

$ composer show --latest 'symfony/*'

Package symfony/lts is abandoned, you should avoid using it. Use symfony/flex instead.
symfony/asset                v4.1.6     = v4.1.6             Symfony Asset Component
symfony/browser-kit          v4.1.6     = v4.1.6             Symfony BrowserKit Component
symfony/cache                v4.1.6     = v4.1.6             Symfony Cache component with PSR-6, PSR-16, and tags
symfony/config               v4.1.6     = v4.1.6             Symfony Config Component
symfony/console              v4.1.6     = v4.1.6             Symfony Console Component
symfony/css-selector         v4.1.6     = v4.1.6             Symfony CssSelector Component
symfony/debug                v4.1.6     = v4.1.6             Symfony Debug Component
symfony/debug-bundle         v4.1.6     = v4.1.6             Symfony DebugBundle
symfony/debug-pack           v1.0.6     = v1.0.6             A debug pack for Symfony projects
symfony/dependency-injection v4.1.6     = v4.1.6             Symfony DependencyInjection Component
symfony/doctrine-bridge      v4.1.6     = v4.1.6             Symfony Doctrine Bridge
symfony/dom-crawler          v4.1.6     = v4.1.6             Symfony DomCrawler Component
symfony/dotenv               v4.1.6     = v4.1.6             Registers environment variables from a .env file
symfony/event-dispatcher     v4.1.6     = v4.1.6             Symfony EventDispatcher Component
symfony/expression-language  v4.1.6     = v4.1.6             Symfony ExpressionLanguage Component
symfony/filesystem           v4.1.6     = v4.1.6             Symfony Filesystem Component
symfony/finder               v4.1.6     = v4.1.6             Symfony Finder Component
symfony/flex                 v1.1.1     = v1.1.1             Composer plugin for Symfony
symfony/form                 v4.1.6     = v4.1.6             Symfony Form Component
symfony/framework-bundle     v4.1.6     = v4.1.6             Symfony FrameworkBundle
symfony/http-foundation      v4.1.6     = v4.1.6             Symfony HttpFoundation Component
symfony/http-kernel          v4.1.6     = v4.1.6             Symfony HttpKernel Component
symfony/inflector            v4.1.6     = v4.1.6             Symfony Inflector Component
symfony/intl                 v4.1.6     = v4.1.6             A PHP replacement layer for the C intl extension that ...
symfony/lts                  dev-master ! dev-master c1affae Enforces Long Term Supported versions of Symfony compo...
symfony/maker-bundle         v1.8.0     = v1.8.0             Symfony Maker helps you create empty commands, control...
symfony/monolog-bridge       v4.1.6     = v4.1.6             Symfony Monolog Bridge
symfony/monolog-bundle       v3.3.0     = v3.3.0             Symfony MonologBundle
symfony/options-resolver     v4.1.6     = v4.1.6             Symfony OptionsResolver Component
symfony/orm-pack             v1.0.5     = v1.0.5             A pack for the Doctrine ORM
symfony/phpunit-bridge       v4.1.6     = v4.1.6             Symfony PHPUnit Bridge
symfony/polyfill-ctype       v1.9.0     = v1.9.0             Symfony polyfill for ctype functions
symfony/polyfill-intl-icu    v1.9.0     = v1.9.0             Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring    v1.9.0     = v1.9.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php72       v1.9.0     = v1.9.0             Symfony polyfill backporting some PHP 7.2+ features to...
symfony/process              v4.1.6     = v4.1.6             Symfony Process Component
symfony/profiler-pack        v1.0.3     = v1.0.3             A pack for the Symfony web profiler
symfony/property-access      v4.1.6     = v4.1.6             Symfony PropertyAccess Component
symfony/property-info        v4.1.6     = v4.1.6             Symfony Property Info Component
symfony/routing              v4.1.6     = v4.1.6             Symfony Routing Component
symfony/security             v4.1.6     = v4.1.6             Symfony Security Component
symfony/security-acl         v3.0.1     = v3.0.1             Symfony Security Component - ACL (Access Control List)
symfony/security-bundle      v4.1.6     = v4.1.6             Symfony SecurityBundle
symfony/serializer           v4.1.6     = v4.1.6             Symfony Serializer Component
symfony/serializer-pack      v1.0.1     = v1.0.1             A pack for the Symfony serializer
symfony/stopwatch            v4.1.6     = v4.1.6             Symfony Stopwatch Component
symfony/swiftmailer-bundle   v3.2.3     ! v3.2.4             Symfony SwiftmailerBundle
symfony/templating           v4.1.6     = v4.1.6             Symfony Templating Component
symfony/translation          v4.1.6     = v4.1.6             Symfony Translation Component
symfony/twig-bridge          v4.1.6     = v4.1.6             Symfony Twig Bridge
symfony/twig-bundle          v4.1.6     = v4.1.6             Symfony TwigBundle
symfony/validator            v4.1.6     = v4.1.6             Symfony Validator Component
symfony/var-dumper           v4.1.6     = v4.1.6             Symfony mechanism for exploring and dumping PHP variables
symfony/web-link             v4.1.6     = v4.1.6             Symfony WebLink Component
symfony/web-profiler-bundle  v4.1.6     = v4.1.6             Symfony WebProfilerBundle
symfony/web-server-bundle    v4.1.6     = v4.1.6             Symfony WebServerBundle
symfony/webpack-encore-pack  v1.0.3     = v1.0.3             A pack for Symfony Encore
symfony/yaml                 v4.1.6     = v4.1.6             Symfony Yaml Component

PHP version

$ php -v
PHP 7.2.10 (cli) (built: Sep 13 2018 00:48:27) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Subject

Steps to reproduce

run
php bin/console sonata:notification:start --env=prod --iteration=250

Expected results

The notif consumer handler starts running and listening for notifs

Actual results

[Sat, 27 Oct 2018 17:14:21 +0000] Checking listeners

In Container.php line 260:
                                                                                                                       
  The "sonata.notification.dispatcher" service or alias has been removed or inlined when the container was compiled.   
  You should either make it public, or stop using the container directly and use dependency injection instead.         
                                                                                                                       

sonata:notification:start [-i|--iteration [ITERATION]] [--type [TYPE]] [-d|--show-details [SHOW-DETAILS]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>


Process finished with exit code 1 at 00:14:21.
Execution time: 494 ms.

Undefined index: exchange

Since updating to #f3f077, we are getting the following error:

Undefined index: exchange in /vendor/sonata-project/notification-bundle/Sonata/NotificationBundle/DependencyInjection/SonataNotificationExtension.php line 104.

The line is:

$exchange = $config['backends']['rabbitmq']['exchange'];

AMQPBackend: typo in AMQPMessage when publishing

In the AMQPBackend handler for rabbitmq the publish method constructs the AMQPMessage object. The properties passes has a typo. The delivery_mode is missed typed as delivery-mode. The consequence is that when the message is delivered to rabbitmq it is not marked as durable as per the documentation here: http://www.rabbitmq.com/tutorials/tutorial-two-python.html see message durability.

This results in all message being lost out of the queue if the rabbitmq server is rebooted with unprocessed messages still in the queue.

CRUDController not found after cache warmup

I can't install the bundle after installing with composer it gives the following error.

Generating autoload files

Fatal error: Class 'Sonata\AdminBundle\Controller\CRUDController' not found in /home/preview/domains/preview.refurls.nl/vendor/sonata-project/notification-bundle/Sonata/NotificationBundle/Controller/MessageAdminController.php on line 21
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.

Get rid of Guzzle depencency

The Guzzle client is only used here:

protected function getApiQueueStatus()
{
if (class_exists('Guzzle\Http\Client') === false) {
throw new \RuntimeException('The guzzle http client library is required to run rabbitmq health checks. Make sure to add guzzle/guzzle to your composer.json.');
}
$client = new \Guzzle\Http\Client();
$client->setConfig(array('curl.options' => array(CURLOPT_CONNECTTIMEOUT_MS => 3000)));
$request = $client->get(sprintf('%s/queues', $this->settings['console_url']));
$request->setAuth($this->settings['user'], $this->settings['pass']);
return json_decode($request->send()->getBody(true), true);
}

This is quite cumbersome to require a big library like guzzle just for do only one request (without service usage BTW).

Plus, you are using Guzzle 3 that is deprecated from a looong time.

It would be great to use a light library or why not just curl.

Or maybe use the php-http abstraction: http://docs.php-http.org/en/latest/integrations/symfony-bundle.html

As guzzle is used internally, requirement drop can be done a new minor.

Doctrine shouldn't be mandatory

Tried to remove Doctrine dependency and had this error:

 [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
  Unable to replace alias "doctrine.orm.default_entity_manager" with "sonata.notification.entity_manager".

  [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
  The service definition "doctrine.orm.default_entity_manager" does not exist.

I have a SQL less application and wish i could remove this dependency.

Can't install version 3.3.0 with composer

PHP version

$ php -v
PHP 7.1.10 (cli) (built: Sep 27 2017 08:27:18) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.10, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans

Subject

When i try to require the newest version of this bundle in an empty Symfony project I get the errors listed below. Other (Sonata) bundles are updating / installing fine. Version 3.2.0 is installing as well.

Steps to reproduce

  • set up new Symfony project or use a existing one.
  • composer require sonata-project/notification-bundle

Expected results

  • installed bundle

Actual results

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing sonata-project/notification-bundle (3.3.0): Downloading (100%)
    Failed to download sonata-project/notification-bundle from dist: Failed to execute unzip -qq -o '/var/www/myproject/vendor/sonata-project/notification-bundle/50e65662ff7cdd3511ce1eedc8b659a6' -d '/var/www/myproject/vendor/composer/ce2c5007'

checkdir error:  cannot create /var/www/myproject/vendor/composer/ce2c5007/sonata-project-SonataNotificationBundle-fa1770b/tests
                 File exists
                 unable to process sonata-project-SonataNotificationBundle-fa1770b/tests/.

    Now trying to download from source
  - Installing sonata-project/notification-bundle (3.3.0): Cloning fa1770b599

Installation failed, reverting ./composer.json to its original content.


  [RuntimeException]
  Failed to execute git checkout 'fa1770b5997f060141fa23d96f119955b87d99f9' -- && git reset --hard 'fa1770b5997f060141fa23d96f119955b87d99f9' --
  error: The following untracked working tree files would be overwritten by checkout:
        .editorconfig
        .gitattributes
        .github/ISSUE_TEMPLATE.md
        .github/PULL_REQUEST_TEMPLATE.md
        .gitignore
        .php_cs
        .php_cs.dist
        .styleci.yml
        .travis.yml
        .travis/after_success_test.sh
        .travis/before_install_test.sh
        .travis/before_script_test.sh
        .travis/check_relevant_docs.sh
        .travis/check_relevant_lint.sh
        .travis/check_relevant_test.sh
        .travis/install_docs.sh
        .travis/install_lint.sh
        .travis/install_test.sh
        CHANGELOG.md
        CONTRIBUTING.md
        LICENSE
        Makefile
        README.md
        Tests/Iterator/AMQPMessageIteratorTest.php
        UPGRADE-3.0.md
        UPGRADE-3.x.md
        composer.json
        docs/Makefile
        docs/_static/.gitkeep
        docs/conf.py
        docs/index.rst
        docs/reference/advanced_configuration.rst
        docs/reference/api.rst
        docs/reference/command_line.rst
        docs/reference/installation.rst
        docs/reference/introduction.rst
        docs/reference/monitoring.rst
        docs/reference/multiple_queues.rst
        docs/reference/usage.rst
        docs/requirements.txt
        phpunit.xml.dist
        src/Admin/MessageAdmin.php
        src/Backend/AMQPBackend.php
        src/Backend/AMQPBackendDispatcher.php
        src/Backend/BackendHealthCheck.php
        src/Backend/BackendInterface.php
        src/Backend/MessageManagerBackend.php
        src/Backend/MessageManagerBackendDispatcher.php
        src/Backend/PostponeRuntimeBackend.php
        src/Backend/QueueBackendDispatcher.php
        src/Backend/QueueDispatcherInterface.php
        src/Backend/RuntimeBackend.php
        src/Command/CleanupCommand.php
        src/Command/ConsumerHandlerCommand.php
        src/Command/CreateAndPublishCommand.php
        src/Command/ListHandlerCommand.php
        src/Command/ListQueuesCommand.php
        src/Command/RestartCommand.php
        src/Consumer/ConsumerEvent.php
        src/Consumer/ConsumerEventInterface.php
        src/Consumer/ConsumerInterface.php
        src/Consumer/ConsumerReturnInfo.php
        src/Consumer/LoggerConsumer.php
        src/Consumer/Metadata.php
        src/Consumer/SwiftMailerConsumer.php
        src/Controller/Api/MessageController.php
        src/Controller/MessageAdminController.php
        src/DependencyInjection/Compiler/NotificationCompilerPass.php
        src/DependencyInjection/Configuration.php
        src/DependencyInjection/SonataNotificationExtension.php
        src/Entity/BaseMessage.php
        src/Entity/MessageManager.php
        src/Event/DoctrineBackendOptimizeListener.php
        src/Event/DoctrineOptimizeListener.php
        src/Event/IterateEvent.php
        src/Event/IterationListener.php
        src/Exception/BackendNotFoundException.php
        src/Exception/HandlingException.php
        src/Exception/InvalidParameterException.php
        src/Form/Type/MessageSerializationType.php
        src/Iterator/AMQPMessageIterator.php
        src/Iterator/ErroneousMessageIterator.php
        src/Iterator/IteratorProxyMessageIterator.php
        src/Iterator/MessageIteratorInterface.php
        src/Iterator/MessageManagerMessageIterator.php
        src/Model/Message.php
        src/Model/MessageInterface.php
        src/Model/MessageManagerInterface.php
        src/Resources/config/admin.xml
        src/Resources/config/api_controllers.xml
        src/Resources/config/api_form.xml
        src/Resources/config/backend.xml
        src/Resources/config/checkmonitor.xml
        src/Resources/config/consumer.xml
        src/Resources/config/core.xml
        src/Resources/config/core_legacy.xml
        src/Resources/config/default_consumers.xml
        src/Resources/config/doctrine/BaseMessage.orm.xml
        src/Resources/config/doctrine/Message.orm.xml.skeleton
        src/Resources/config/doctrine_orm.xml
        src/Resources/config/event.xml
        src/Resources/config/routing/api.xml
        src/Resources/config/selector.xml
        src/Resources/config/serializer/Model.Message.xml
        src/Resources/config/validation.xml
        src/Resources/meta/LICENSE
        src/Resources/translations/SonataNotificationBundle.cs.xliff
        src/Resources/translations/SonataNotificationBundle.de.xliff
        src/Resources/translations/SonataNotificationBundle.en.xliff
        src/Resources/translations/SonataNotificationBundle.es.xliff
        src/Resources/translations/SonataNotificationBundle.fr.xliff
        src/Resources/translations/SonataNotificationBundle.it.xliff
        src/Resources/translations/SonataNotificationBundle.nl.xliff
        src/Resources/translations/SonataNotificationBundle.ru.xliff
        src/Resources/translations/SonataNotificationBundle.sk.xliff
        src/Resources/tra
  Aborting

Remove dependency's to Sonata Admin

I want to use the SonataNotificationBundle because it has an abstract way for sending messes to a Message Queue's but the current version depends on the Sonata Admin. If I try to install this the current 2.1 version it wants to install an other version of the KpnMenuBundle wich i'm also using because of the Sonata Admin requirement. What I want to do is use the doctrine handler for know and later be apple to switch to RabbitMQ.

I have remove the dependency in a fork of the project and it works like a charm for me know.
cmodijk/SonataNotificationBundle@ea8baf61473f228f7d70a02f38cc9e14eb86c2a8

Make MessageManagerMessageIterator in MessageManagerBackend configurable

Hey,

first thanks for sharing this bundle!

I would like to provide a custom implementation of the MessageManagerMessageIterator. Since currently this class is created directly within the MessageManagerBackend->getIterator() it is hard to do so.

Exposing this class as a service and injecting it into the backend would be perfect.

Please let me know it this is possible. Also please let me know if you want me to provide an implementation (pull request).

Kind regards
Hannes

Support for multiple channels

I'm currently evaluating the bundle for a project, and if i understand the implementation correctly, you can process messages only on a single channel when using the rabbitMQ backend.

This means long-running messages will block short messages. In our use case, we need separate channels, so for example video transcoding consumers don't block email-notification consumers.

Would you accept a PR to support this functionality or do you see this as a problem with the current implementation?

Detached messages are duplicated by the MessageManager

-Description

If MessageManager::save() encounters a detached $message it tries to merge it:

$this->getEntityManager()->getUnitOfWork()->merge($message);

This code returns a new managed instance, but it is not assigned to $message.

Thus the old, unmanaged version of the message is passed down and persisted when calling:
parent::save($message, $andFlush)

This results in a duplicate entry of the message.

-Steps to reproduce

To reproduce this I set up the bundle with doctrine (using the default connection and entity manger).
With this setup calling $em->clear() during ConsumerInterface::process() results in a duplicate message (in DB) for each processed message

-Proposed solution

I reckon this should do the trick:

$message = $this->getEntityManager()->getUnitOfWork()->merge($message);

Doctrine backend message queue iterator order

I have noticed an issue where messages are not being processed in the order they are put in. This is how I would expect the queue to work: FIFO

Upon inspection it looks like message iterator is picking a few messages (bufferSize) and doing array_pop on them. This doesn't sound ok to me? Am I missing something?

Regards,
Gregor

[rabbitmq] Support for dead letter exchanges

Use case

Before i start with a longer PR, id' like to propose the following change to the rabbitmq backend: Right now there is now support for dead letter exchanges (please correct me if i missed something).

The use case is the following:

  • Your app transcodes audio/video files in a rabbitmq consumer
  • The consumer crashes when executing some transcoding app like ffmpeg
  • As the handler does not send a basic_ack back to rabbitmq, the broker will send the message to the next available consumer
  • The consumer will fail again due to the faulty media file, resulting in a stuck queue.

Implementation

The dead letter exchange would solve this use case. To add support for it, i'd implement the following changes:

  • Add another parameter to the queues node of the rabbitmq configuration
  • This parameter will specifiy how to handle failed messages (basic.reject | basic.nack |ย basic_ack)
  • If a queue is configured to use basic.reject or basic.nack for failed messages, the exchange will be declared using a x-dead-letter-exchange attribute which can be configured too, but will be set to some default value.

What do you think?

Asynchronous queues

Hello, can I make async queue based on sonata.notification.backend.doctrine with this package? I don't saw any info about it in documentation..

Control RabbitMQ prefetch settings from the config

Subject

I've been using SonataNotificationBundle with RabbitMQ. I am running 2 queues under the same type "example_type". However I am missing the option to control the prefetch settings. I think it would be wise to add something to the configuration to change the prefetch settings.

So as explained by RabbitMQ under the Fair dispatch chapter a queue can receive heavy and less heavy tasks (messages). One of my consumers is receiving a very heavy task and is busy quite some time depending on the amount of data to process. The other should then continue to process tasks but because prefetch is not set to 1 some tasks are not processed. For more information see "Steps to Reproduce".

Steps to reproduce

We have Task A, B and C.
A = Long task
B = Short task
C = Short task

We have 2 consumers running:
D and E

Queue all messages in order A, B, C.

Consumer D shall receive Task A from RabbitMQ.
Consumer E shall receive Task B from RabbitMQ.
Consumer D shall receive Task C from RabbitMQ.

Consumer E finishes before D. But because Task C is assigned to Consumer D instead of being still in queue Consumer E is now not doing anything. Consumer E should however process Task C.

Expected results

Consumer E not being idle because message was assigned to a busy consumer.

Actual results

Consumer E is idle. Consumer D processes Task C after task A.

TL;DR: There should be an option in the config to control the prefetch settings (in case of RabbitMQ).

sonata notification bundle

i want to ask if sonata NotificationBundle is avaible for symfony 2.4
because config mapping is autoloded in symfony 2.4
i don't know where to put (entity_managers:
default:
# ...
mappings:
# ...
SonataNotificationBundle: ~
ApplicationSonataNotificationBundle: ~)

Update to 3.3.0 backend error: Could not load type "Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter": class does not implement "Symfony\Component\Form\FormTypeInterface".

Environment

Linux mydev7 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.26.0          3.31.0             The missing Symfony Admin Generator
sonata-project/block-bundle              3.11.0          3.11.0             Symfony SonataBlockBundle
sonata-project/cache                     1.1.1           2.0.1              Cache library
sonata-project/cache-bundle              2.4.0           2.4.0              This bundle provides caching services
sonata-project/core-bundle               3.9.0           3.9.0              Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1           2.3.1              Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2           1.0.2              Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.3.0           3.4.1              Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.4.0           2.4.0              Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0           1.8.0              Lightweight Exporter library
sonata-project/google-authenticator      1.1.0           2.0.0              Library to integrate Google Authenticator into a PHP project
sonata-project/intl-bundle               2.4.0           2.4.0              Symfony SonataIntlBundle
sonata-project/media-bundle              3.10.0          3.10.0             Symfony SonataMediaBundle
sonata-project/notification-bundle       3.2.0           3.3.0              Symfony SonataNotificationBundle
sonata-project/page-bundle               3.x-dev a719702 dev-master 2047cb4 This bundle provides a Site and Page management through container and block services
sonata-project/seo-bundle                2.5.0           2.5.0              Symfony SonataSeoBundle
sonata-project/user-bundle               3.6.0           4.1.0              Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v2.12.1 v3.1.2 Symfony MonologBundle
symfony/phpunit-bridge     v2.8.33 v4.0.3 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.6.0  v1.6.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.6.0  v1.6.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.6.0  v1.6.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.6.0  v1.6.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1  v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.1  v3.1.6 Symfony SwiftmailerBundle
symfony/symfony            v2.8.33 v4.0.3 The Symfony PHP framework

PHP version

$ php -v
PHP 7.1.12-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec 14 2017 15:37:13) ( NTS )

Upgrade to 3.3.0 crashes the list view in the backend.

Stacktrace

[1] Symfony\Component\Form\Exception\InvalidArgumentException: Could not load type "Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter": class does not implement "Symfony\Component\Form\FormTypeInterface".
    at n/a
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php line 91

    at Symfony\Component\Form\FormRegistry->getType('Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter')
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php line 100

    at Symfony\Component\Form\FormFactory->createNamedBuilder('value', 'Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter', null, array('required' => false, 'choices' => array('open', 'in_progress', 'done', 'error', 'cancelled')))
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 106

    at Symfony\Component\Form\FormBuilder->create('value', 'Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter', array('required' => false, 'choices' => array('open', 'in_progress', 'done', 'error', 'cancelled')))
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 269

    at Symfony\Component\Form\FormBuilder->resolveChildren()
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 215

    at Symfony\Component\Form\FormBuilder->getForm()
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 221

    at Symfony\Component\Form\FormBuilder->getForm()
        in /var/www/project/vendor/sonata-project/admin-bundle/src/Datagrid/Datagrid.php line 146

    at Sonata\AdminBundle\Datagrid\Datagrid->buildPager()
        in /var/www/project/vendor/sonata-project/admin-bundle/src/Datagrid/Datagrid.php line 317

    at Sonata\AdminBundle\Datagrid\Datagrid->getForm()
        in /var/www/project/vendor/sonata-project/admin-bundle/src/Controller/CRUDController.php line 108

    at Sonata\AdminBundle\Controller\CRUDController->listAction()
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 135

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 57

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php line 67

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in /var/www/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php line 183

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in /var/www/project/web/app_dev.php line 28

Downgrade to 3.2.0 solves the problem.

Unknown Doctrine JSON data type

While running doctrine:schema:update I get the following exception:

[Doctrine\DBAL\DBALException]
Unknown column type json requested.

The notification__message table has a body field of type json which is not implemented.

Symfony 2.2 Problem

For now I cant install sonatamediabundle.
Please fix compatibility for symfony 2.2

Monitoring worker scripts

This is rather a question than an issue: Are there any best practices on how to monitor worker scripts? E.g. check if they still respond and work correctly? We're using supervisord to run the workers, but have already had some situations where supervisord has reported the consumer as running, but the consumer failed internally.

set return path for SwiftmailerConsumer

Feature Request

Hi I would like to be able to set the return-path for an email using the swift mailer consumer for bounce handling purposes.

allow the user to set an array item in message body to the notification consumer.

'returnPath' => [
    'email' => '[email protected]',
]

Change the src/consumer/swiftmailconsumer.php add the returnPath.

    /**
     * @param MessageInterface $message
     */
    private function sendEmail(MessageInterface $message)
    {
        $mail = $this->mailer->createMessage()
            ->setSubject($message->getValue('subject'))
            ->setFrom([$message->getValue(['from', 'email']) => $message->getValue(['from', 'name'])])
            ->setTo($message->getValue('to'));
        if ($replyTo = $message->getValue('replyTo')) {
            $mail->setReplyTo($replyTo);
        }

        /* New element here
        if ($returnPath = $message->getValue('returnPath')) {
            $mail-> setReturnPath($returnPath);
        }
        */

        if ($cc = $message->getValue('cc')) {
            $mail->setCc($cc);
        }
        if ($bcc = $message->getValue('bcc')) {
            $mail->setBcc($bcc);
        }
        if ($text = $message->getValue(['message', 'text'])) {
            $mail->addPart($text, 'text/plain');
        }
        if ($html = $message->getValue(['message', 'html'])) {
            $mail->addPart($html, 'text/html');
        }
        if ($attachment = $message->getValue(['attachment', 'file'])) {
            $attachmentName = $message->getValue(['attachment', 'name']);
            $mail->attach(new \Swift_Attachment($attachment, $attachmentName));
        }

        $this->mailer->send($mail);
    }

ContainerAwareEventDispatcher deprecated

Subject

Starting Symfony the use of Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher is deprecated and will give the following warning:
The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since version 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead:

It would be beneficial if this old interface could be swapped with the new one

Steps to reproduce

Install sonata notification with Symfony 3.3

Expected results

No warnings on unit tests

Actual results

The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since version 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead:

Running tasks simultaneously

Feature Request

Would be nice to have ability to run tasks all together and not one by one, when sonata:notification:start is called... but maybe I'm a dreamer?

TypeError when a message is published from AMQPBackend

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.45.2          3.46.0             The missing Symfony Admin Generator
sonata-project/block-bundle              3.15.0          3.15.0             Symfony SonataBlockBundle
sonata-project/cache                     2.0.1           2.0.1              Cache library
sonata-project/classification-bundle     3.8.0           3.8.0              Symfony SonataClassificationBundle
sonata-project/core-bundle               3.16.1          3.16.2             Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.4.0           3.0.0              Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.1.5           1.2.0              Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.8.3           3.8.3              Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.5.0           2.5.0              Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.0.1           2.0.1              Lightweight Exporter library
sonata-project/intl-bundle               2.5.0           2.5.0              Symfony SonataIntlBundle
sonata-project/media-bundle              3.x-dev a190425 dev-master 5ed0c07 Symfony SonataMediaBundle
sonata-project/notification-bundle       3.6.0           3.6.0              Symfony SonataNotificationBundle
sonata-project/translation-bundle        2.4.1           2.4.1              SonataTranslationBundle
sonata-project/user-bundle               4.3.0           4.3.0              Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
Restricting packages listed in "symfony/symfony" to "4.2.*"
symfony/asset                v4.1.11 v4.2.4  Symfony Asset Component
symfony/browser-kit          v4.2.4  v4.2.4  Symfony BrowserKit Component
symfony/cache                v4.2.4  v4.2.4  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/config               v4.2.4  v4.2.4  Symfony Config Component
symfony/console              v4.1.11 v4.2.4  Symfony Console Component
symfony/contracts            v1.0.2  v1.0.2  A set of abstractions extracted out of the Symfony components
symfony/css-selector         v4.2.4  v4.2.4  Symfony CssSelector Component
symfony/debug                v4.2.4  v4.2.4  Symfony Debug Component
symfony/debug-bundle         v4.2.4  v4.2.4  Symfony DebugBundle
symfony/debug-pack           v1.0.7  v1.0.7  A debug pack for Symfony projects
symfony/dependency-injection v4.2.4  v4.2.4  Symfony DependencyInjection Component
symfony/doctrine-bridge      v4.2.4  v4.2.4  Symfony Doctrine Bridge
symfony/dom-crawler          v4.2.4  v4.2.4  Symfony DomCrawler Component
symfony/dotenv               v4.1.11 v4.2.4  Registers environment variables from a .env file
symfony/event-dispatcher     v4.2.4  v4.2.4  Symfony EventDispatcher Component
symfony/expression-language  v4.1.11 v4.2.4  Symfony ExpressionLanguage Component
symfony/filesystem           v4.2.4  v4.2.4  Symfony Filesystem Component
symfony/finder               v4.2.4  v4.2.4  Symfony Finder Component
symfony/flex                 v1.2.0  v1.2.0  Composer plugin for Symfony
symfony/form                 v4.1.11 v4.2.4  Symfony Form Component
symfony/framework-bundle     v4.1.11 v4.2.4  Symfony FrameworkBundle
symfony/http-foundation      v4.2.4  v4.2.4  Symfony HttpFoundation Component
symfony/http-kernel          v4.1.11 v4.2.4  Symfony HttpKernel Component
symfony/inflector            v4.2.4  v4.2.4  Symfony Inflector Component
symfony/intl                 v4.2.4  v4.2.4  A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/maker-bundle         v1.11.4 v1.11.5 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/monolog-bridge       v4.2.4  v4.2.4  Symfony Monolog Bridge
symfony/monolog-bundle       v3.3.1  v3.3.1  Symfony MonologBundle
symfony/options-resolver     v4.2.4  v4.2.4  Symfony OptionsResolver Component
symfony/orm-pack             v1.0.6  v1.0.6  A pack for the Doctrine ORM
symfony/panther              v0.3.0  v0.3.0  A browser testing and web scraping library for PHP and Symfony.
symfony/phpunit-bridge       v4.2.4  v4.2.4  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu    v1.10.0 v1.10.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring    v1.10.0 v1.10.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72       v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/process              v4.1.11 v4.2.4  Symfony Process Component
symfony/profiler-pack        v1.0.4  v1.0.4  A pack for the Symfony web profiler
symfony/property-access      v4.2.4  v4.2.4  Symfony PropertyAccess Component
symfony/property-info        v4.2.4  v4.2.4  Symfony Property Info Component
symfony/routing              v4.2.4  v4.2.4  Symfony Routing Component
symfony/security             v4.2.4  v4.2.4  Symfony Security Component
symfony/security-acl         v3.0.1  v3.0.1  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle      v4.1.11 v4.2.4  Symfony SecurityBundle
symfony/serializer           v4.2.4  v4.2.4  Symfony Serializer Component
symfony/serializer-pack      v1.0.2  v1.0.2  A pack for the Symfony serializer
symfony/stopwatch            v4.2.4  v4.2.4  Symfony Stopwatch Component
symfony/swiftmailer-bundle   v3.2.5  v3.2.5  Symfony SwiftmailerBundle
symfony/templating           v4.1.11 v4.2.4  Symfony Templating Component
symfony/test-pack            v1.0.5  v1.0.5  A pack for functional and end-to-end testing within a Symfony app
symfony/translation          v4.1.11 v4.2.4  Symfony Translation Component
symfony/twig-bridge          v4.1.11 v4.2.4  Symfony Twig Bridge
symfony/twig-bundle          v4.1.11 v4.2.4  Symfony TwigBundle
symfony/validator            v4.1.11 v4.2.4  Symfony Validator Component
symfony/var-dumper           v4.2.4  v4.2.4  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter         v4.2.4  v4.2.4  A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link             v4.1.11 v4.2.4  Symfony WebLink Component
symfony/web-profiler-bundle  v4.1.11 v4.2.4  Symfony WebProfilerBundle
symfony/web-server-bundle    v4.1.11 v4.2.4  Symfony WebServerBundle
symfony/yaml                 v4.1.11 v4.2.4  Symfony Yaml Component

PHP version

$ php -v
PHP 7.2.16-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Mar  7 2019 20:23:06) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.16-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans

Subject

The following TypeError occurs when a message is published from AMQPBackend:

Argument 1 passed to Interop\Amqp\Impl\AmqpMessage::setTimestamp() must be of the type integer or null, string given, called in /home/jo66/www/bizbox/vendor/sonata-project/notification-bundle/src/Backend/AMQPBackend.php on line 170

Steps to reproduce

  • Configure notification bundle with rabbitmq and AmqpLib.
  • Publish a message.

Expected results

Message published.

Actual results

Following error.

TypeError:
Argument 1 passed to Interop\Amqp\Impl\AmqpMessage::setTimestamp() must be of the type integer or null, string given, called in /home/jo66/www/bizbox/vendor/sonata-project/notification-bundle/src/Backend/AMQPBackend.php on line 170

at vendor/queue-interop/amqp-interop/src/Impl/AmqpMessage.php:155
at Interop\Amqp\Impl\AmqpMessage->setTimestamp('1552402842')
(vendor/sonata-project/notification-bundle/src/Backend/AMQPBackend.php:170)
at Sonata\NotificationBundle\Backend\AMQPBackend->publish(object(Message))
(vendor/sonata-project/notification-bundle/src/Backend/AMQPBackend.php:197)
at Sonata\NotificationBundle\Backend\AMQPBackend->createAndPublish('create_server', array('sleep' => '3'))
(vendor/sonata-project/notification-bundle/src/Backend/QueueBackendDispatcher.php:77)
at Sonata\NotificationBundle\Backend\QueueBackendDispatcher->createAndPublish('create_server', array('sleep' => '3'))
(src/Admin/ServerInstanceAdmin.php:103)
at App\Admin\ServerInstanceAdmin->postPersist(object(ServerInstance))
(vendor/sonata-project/admin-bundle/src/Admin/AbstractAdmin.php:697)
at Sonata\AdminBundle\Admin\AbstractAdmin->create(object(ServerInstance))
(vendor/sonata-project/admin-bundle/src/Controller/CRUDController.php:619)
at Sonata\AdminBundle\Controller\CRUDController->createAction()
(vendor/symfony/http-kernel/HttpKernel.php:149)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:66)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:188)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public/index.php:25)

Message emitting new messages

Hello, I'm using messages that will in turn create new messages.

And it's not working in dev side.

Problem is, the %sonata.notification.backend.postpone% service uses a simple array and an iterator to iterate on messages. Therefore newly created messages are thrown away.

%sonata.notification.backend.runtime% throws a Maximum function nesting level reached Exception

And we don't setup rabbit mq on developing side because it would be to much.

I'll try to bring a fix to that really soon, if you have any suggestion...

Thanks ๐Ÿ‘

php 7.2 The each() function is deprecated

The each() function is deprecated in php 7.2.

Please fix: sonata-project/notification-bundle/src/Backend/PostponeRuntimeBackend.php
line 82
while (list($key, $message) = each($this->messages)) {
$this->handle($message, $this->dispatcher);
}

on

foreach($this->messages as $key => $message){
$this->handle($message, $this->dispatcher);
}

PostponeRuntimeBackend generate an error

Since the last update about PostponeRuntimeBackend, i have the following error on all pages (at the bottom of the page) :

Warning: Invalid argument supplied for foreach() in D:\www###\vendor\sonata-project\notification-bundle\Sonata\NotificationBundle\Backend\PostponeRuntimeBackend.php line 56

Did I miss a new config ?

Here is the complete trace :

in D:\www###\vendor\sonata-project\notification-bundle\Sonata\NotificationBundle\Backend\PostponeRuntimeBackend.php line 56
at ErrorHandler->handle('2', 'Invalid argument supplied for foreach()', 'D:\www###\vendor\sonata-project\notification-bundle\Sonata\NotificationBundle\Backend\PostponeRuntimeBackend.php', '56', array('event' => object(PostResponseEvent))) in D:\www###\vendor\sonata-project\notification-bundle\Sonata\NotificationBundle\Backend\PostponeRuntimeBackend.php line 56
at PostponeRuntimeBackend->onEvent(object(PostResponseEvent))
at call_user_func(array(object(PostponeRuntimeBackend), 'onEvent'), object(PostResponseEvent)) in D:\www###\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher.php line 139
at ContainerAwareTraceableEventDispatcher->doDispatch(array(array(object(PostponeRuntimeBackend), 'onEvent'), array(object(EmailSenderListener), 'onKernelTerminate')), 'kernel.terminate', object(PostResponseEvent)) in D:\www###\app\cache\dev\classes.php line 4715
at EventDispatcher->dispatch('kernel.terminate', object(PostResponseEvent)) in D:\www###\app\cache\dev\classes.php line 4933
at ContainerAwareEventDispatcher->dispatch('kernel.terminate', object(PostResponseEvent)) in D:\www###\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher.php line 78
at ContainerAwareTraceableEventDispatcher->dispatch('kernel.terminate', object(PostResponseEvent)) in D:\www###\app\bootstrap.php.cache line 1403
at HttpKernel->terminate(object(Request), object(Response)) in D:\www###\app\bootstrap.php.cache line 589
at Kernel->terminate(object(Request), object(Response)) in D:\www###\web\app_dev.php line 30

(How) can I use this bundle for onpage notifications?

I want to include notifications, e.g. for forum threads. A user shall retrieve notifications if there are any new posts to a forum thread. Another example would be the notifications on Facebook, e.g. where you're notified of new comments on your posts or pictures.

I came up with this bundle but I am unsure if this is what I really need. When I look at the usage examples it looks as if this would provide a email notification function

// retrieve the notification backend
$backend = $container->get('sonata.notification.backend');

// create and publish a message
$backend->createAndPublish('mailer', array(
    'from' => array(
        'email' => '[email protected]',
        'name'  => 'No Reply'
    ),
    'to'   => array(
        '[email protected]' => 'My User',
        '[email protected]' => 'My User 1',
    ),
    'message' => array(
        'html' => '<b>hello</b>',
        'text' => 'hello'
    ),
    'subject' => 'Contact form',
));

or a logging function

$this->get('sonata.notification.backend')->createAndPublish('logger', array(
    'level' => 'debug',
    'message' => 'Hello world!'
));

Can you confirm/recommend the usage of that bundle? Or can you recommend any other bundle?

non-existent service "sonata.notification.manager.message"

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle        3.33.0 3.33.0 The missing Symfony Admin Generator
sonata-project/block-bundle        3.12.1 3.12.1 Symfony SonataBlockBundle
sonata-project/cache               1.0.7  1.0.7  Cache library
sonata-project/core-bundle         3.9.1  3.9.1  Symfony SonataCoreBundle
sonata-project/datagrid-bundle     2.3.1  2.3.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions 1.0.2  1.0.2  Doctrine2 behavioral extensions
sonata-project/easy-extends-bundle 2.5.0  2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter            1.8.0  1.8.0  Lightweight Exporter library
sonata-project/media-bundle        3.11.0 3.11.0 Symfony SonataMediaBundle
sonata-project/notification-bundle 3.4.0  3.4.0  Symfony SonataNotificationBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/assetic-bundle     v2.8.2  v2.8.2 Integrates Assetic into Symfony2
symfony/monolog-bundle     v2.12.1 v3.2.0 Symfony MonologBundle
symfony/polyfill-apcu      v1.7.0  v1.7.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-iconv     v1.7.0  v1.7.0 Symfony polyfill for the Iconv extension
symfony/polyfill-intl-icu  v1.7.0  v1.7.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.7.0  v1.7.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54     v1.7.0  v1.7.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55     v1.7.0  v1.7.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56     v1.7.0  v1.7.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.7.0  v1.7.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.7.0  v1.7.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1  v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7  v3.2.2 Symfony SwiftmailerBundle
symfony/symfony            v2.8.36 v3.4.7 The Symfony PHP framework

PHP version

$ php -v
PHP 7.0.28-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.28-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

Unable to upgrade to 3.x

After setting up the dependencies to "sonata-project/notification-bundle": "^3.3" I tried to update and got the following results.

$ composer update sonata-project/notification-bundle
Loading composer repositories with package information
Updating dependencies (including require-dev)                        
Nothing to install or update
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Package kphoen/doctrine-state-machine is abandoned, you should avoid using it. No replacement was suggested.
Package kphoen/doctrine-state-machine-bundle is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
> ComponentInstaller\Installer::postAutoloadDump
Compiling component files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
Updating the "app/config/parameters_dev.yml" file
Class AppBundle\Composer\postInstallSymlinkVendors is not autoloadable, can not call post-update-cmd script
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

                                                                                                                                              
  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                                                                  
  The service "sonata.notification.controller.api.message" has a dependency on a non-existent service "sonata.notification.manager.message".  
                                                                                                                                              

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

                                                                                                                                                                  
  [RuntimeException]                                                                                                                                              
  An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                       
                                                                                                                                                                  
                                                                                                                                                                  
                                                                                                                                                                  
                                                                                                                                                                  
                                                                                                                                                  
    [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                                                                    
    The service "sonata.notification.controller.api.message" has a dependency on a non-existent service "sonata.notification.manager.message".    
                                                                                                                                                  
                                                                                                                                                                  
  .                                                                                                                                                               
                                                                                                                                                                  

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

I double-checked the installation and configuration documentation for this version and got this after following all of the steps.

Terminating the sonata:notification:start process breaks a notification that is currently handled

I'm using the sonata:notification:start command with supervisor as described in the documentation. While dealing with some longer running consumers, i have encountered the following problem:

When restarting the sonata:notification:start process (e.g. on deployment) with "supervisorctl restart" while a notification is "in process", the process is killed immediately by supervisor. The current notification is not processed completely and stays in the queue with state "in process" forever as it seems. It can even break your application, if it depends on fully processed notifications in some way.

So, it would be nice, to let the current iteration finish before exiting the process.

I have experimented a bit with the pcntl functions and this seams to work from console (ctrl+c) and with supervisor (supervisorctl restart):

private $shouldStop = false;

public function execute(InputInterface $input, OutputInterface $output)
{
    pcntl_signal(SIGTERM, [$this, 'stopCommand']);
    pcntl_signal(SIGINT, [$this, 'stopCommand']);

    $this->shouldStop = false;

    while (true) {
        pcntl_signal_dispatch();
        if ($this->shouldStop) {
            break;
        }
        $output->write('Do some work');

        for($i = 0; $i < 10; $i++) {
            sleep(1);
            $output->write('.');
        }

        $output->writeln('done!');
    }
}

protected function stopCommand()
{
    $this->shouldStop = true;
}

What do you think about such a solution, maybe as an optional "safe" mode?
Or any ideas to handle this otherwise?

Found something similar here: https://github.com/videlalvaro/RabbitMqBundle/blob/master/Command/BaseConsumerCommand.php

SonataEasyExtendsBundle not included by default in Notification

I had to manually add the bundle to the AppKernel while installing the Notification bundle:

new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),

However that is undocumented in the previously linked file. I think the Notification bundle should include it automatically OR it should be noted in the documentation. I didn't edit the documentation directly since it might be a bug in the bundle instead of a documentation issue.

Missed requirements for zendframework/zenddiagnostics

here is the deal

  • notification backends use ZendDiagnostics\Result\Success from package zendframework/zenddiagnostics
  • zendframework/zenddiagnostics is required for liip/monitor-bundle
  • but liip/monitor-bundle is mentioned as suggested bundle for this bundle
  • error will not occur until app call for for \Sonata\NotificationBundle\Backend\PostponeRuntimeBackend::getStatus

so for proper package deps either liip/monitor-bundle is required for this bundle or this bundle cannot use ZendDiagnostics\Result\Success in backends

[rfc] Migration to AMQP interop

Would you be interested to migrate to amqp interop.

The biggest advantage among others is that it would work with php-amqplib, amqp-ext, and bunny libraries.

If you are fine with it I can work on a PR.

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.