FOSElasticaBundle
FOSElasticaBundle copied to clipboard
Not full support for Symfony 5 - FOSElasticaBundle 6 is not compatible with enqueue/elastica-bundle
I am using Symfony 5.1, FOSElasticaBundle 6.0 and Elasticsearch 7.* without any problems, everything works fine. I want to speed up populate command as it is specified in the doc. But it is not possible to install the package "enqueue/elastica-bundle" with FOSElasticaBundle 6.0, it is forcing me to dowgrande FOSElasticaBundle to 5.0
I guess someone will have to increase the dependency at enqueue/elastica-bundle https://github.com/php-enqueue/enqueue-elastica-bundle/blob/master/composer.json#L10
I increased locally the FOSElasticaBundle dependency in enqueue/elastica-bundle to match 6.0. I could install it but after clearing the cache I get the next error: [critical] Uncaught Error: Class 'FOS\ElasticaBundle\Persister\Event\Events' not found Checking the changelog I saw that Event class and other files were removed. How can I get this working with enqueue/elastica-bundle support? I need to speed up the populate command for FOSElasticaBundle and I am using Symfony5 and I do not want to downgrade my entire project along elasticsearch etc In case that it is not possible, is there any other alternative way to do it? Maybe executing the populate command in the terminal through a cronjob?
If you're just installing enqueue/elastica-bundle specifically for this action, you can also:
- require
symfony/messenger - add entry to
fos_elastica.yaml
fos_elastica:
messenger: ~
- run
bin/console fos:elastica:populate --pager-persister=async.
Thanks for your suggestion @darthf1 !! In my case I think that messenger library will be enough because I only need to speed up the populate command. So I am reading now the documentation for symfony/messenger to see if I am missing some configuration but I followed your steps and when I try to execute the populate command it returns me this error:
In HandleMessageMiddleware.php line 73:
No handler for message "FOS\ElasticaBundle\Message\AsyncPersistPage".
Try registering the handler yourself. I had similar issues in https://github.com/FriendsOfSymfony/FOSElasticaBundle/issues/1720
FOS\ElasticaBundle\Message\Handler\AsyncPersistPageHandler:
autoconfigure: false
arguments:
$persister: '@fos_elastica.async_pager_persister'
tags: [{ name: messenger.message_handler, bus: command.bus }]
https://symfony.com/doc/current/messenger.html#manually-configuring-handlers
I guess we will have to add the AsyncPersistPageHandler service to https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/src/Resources/config/messenger.xml
Can you check if https://github.com/FriendsOfSymfony/FOSElasticaBundle/pull/1739 fixes the issue?
And https://github.com/php-enqueue/enqueue-elastica-bundle/pull/33
@blackdolphin65 https://github.com/php-enqueue/enqueue-elastica-bundle/pull/33 has been merged, there is no need to fork that repository anymore.
@XWB Sorry for the late reply, I had some personal problems and I could not check it before. The PR that was merged works fine and it fixes the issue. Thanks!
@darthf1 I followed your changes in #1720 and I could update foselasticsearch objects executing:
php bin/console fos:elastica:populate --pager-persister=async
Previous command works without any problem, my current issue is that if I add or modify an an entity mapped in fos_elastica.yaml it is not consumed by the messenger. Maybe I missed something as I am new to messenger
Apart from your configuration in fos_elastica.yaml I have disabled the default listener under persistence section:
listener: { enabled: false }
As messenger transport I used MESSENGER_TRANSPORT_DSN=doctrine://default and I checked that symfony/doctrine-messenger is installed
I also want to use supervisord but before that I want to check "manually" that everything is working fine. For that I executed the next commands:
php bin/console messenger:consume -vv priority default --time-limit=3600
php bin/console messenger:consume -vv elasticsearch --limit=10 --time-limit=3600
Both commands are being executed without any issue or warning, then I proceed to create and edit mapped entities in foselasticasearch to check if messages are dispatched and consumed but unfortunately they are not
Also I have one doubt, once messages are properly consumed will be all entities reseted or only the new entity will be added or the unique entity edited modified? Because if I am going only to do an addition or modification, it won't be needed reset everything in elasticsearch
P.S. Also when the new version is released, this part of the documentation will become outdated. I think that the configuration added by @darthf1 in #1720 could be useful for others who try to speed up the populate command
@XWB Sorry for the late reply, I had some personal problems and I could not check it before. The PR that was merged works fine and it fixes the issue. Thanks!
@darthf1 I followed your changes in #1720 and I could update foselasticsearch objects executing:
php bin/console fos:elastica:populate --pager-persister=asyncPrevious command works without any problem, my current issue is that if I add or modify an an entity mapped in
fos_elastica.yamlit is not consumed by the messenger. Maybe I missed something as I am new to messengerApart from your configuration in
fos_elastica.yamlI have disabled the default listener under persistence section:
listener: { enabled: false }As messenger transport I used
MESSENGER_TRANSPORT_DSN=doctrine://defaultand I checked thatsymfony/doctrine-messengeris installedI also want to use supervisord but before that I want to check "manually" that everything is working fine. For that I executed the next commands:
php bin/console messenger:consume -vv priority default --time-limit=3600
php bin/console messenger:consume -vv elasticsearch --limit=10 --time-limit=3600Both commands are being executed without any issue or warning, then I proceed to create and edit mapped entities in foselasticasearch to check if messages are dispatched and consumed but unfortunately they are not
Also I have one doubt, once messages are properly consumed will be all entities reseted or only the new entity will be added or the unique entity edited modified? Because if I am going only to do an addition or modification, it won't be needed reset everything in elasticsearch
P.S. Also when the new version is released, this part of the documentation will become outdated. I think that the configuration added by @darthf1 in #1720 could be useful for others who try to speed up the populate command
hey, I have same problem. is there any way to fix it?