Command "symfony console messenger:failed:show" not working - symfony

I am working the Symfony Fast Track Chapter 18.3
Configuring the Messenger Configuration (config/packages/messenger.yaml):
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
auto_setup: false
use_notify: true
check_delayed_interval: 60000
retry_strategy:
max_retries: 3
multiplier: 2
failed:
dsn: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
App\Message\CommentMessage: async
The Messenger daemon is started
But when I run the following command I get the error Message below:
jpmena#jpmena-300E4A-300E5A-300E7A-3430EA-3530EA:~/CONSULTANT/FASTTRACK/DEV/guestbook$ symfony console messenger:failed:show
There are no commands defined in the "messenger:failed" namespace.
Did you mean this?
messenger
What is wrong in my configuration?

I think your forget to remove comment on "failure_transport" line
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
failure_transport: failed <-- remove comment here

Related

Symfony messenger install for mailer: PHP Warning: PHP Startup: Unable to load dynamic library 'amqp.so'

When I run composer require symfony/mailer
I have this screen:
If you want to send emails asynchronously:
1. Install the messenger component by running composer require messenger;
2. Add 'Symfony\Component\Mailer\Messenger\SendEmailMessage': amqp to the
config/packages/messenger.yaml file under framework.messenger.routing
and replace amqp with your transport name of choice.
I run composer require messenger
My config/packages/messenger.yaml:
framework:
messenger:
failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
use_notify: true
check_delayed_interval: 60000
retry_strategy:
max_retries: 3
multiplier: 2
failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
routing:
#Symfony\Component\Mailer\Messenger\SendEmailMessage: async
Symfony\Component\Mailer\Messenger\SendEmailMessage: amqp
Symfony\Component\Notifier\Message\ChatMessage: async
Symfony\Component\Notifier\Message\SmsMessage: async
# Route your messages to the transports
#'App\Message\YourMessage': async
I have now :
PHP Warning: PHP Startup: Unable to load dynamic library 'amqp.so'
(tried: /usr/lib/php/20200930/amqp.so (/usr/lib/php/20200930/amqp.so:
cannot open shared object file: No such file or directory),
/usr/lib/php/20200930/amqp.so.so (/usr/lib/php/20200930/amqp.so.so:
cannot open shared object file: No such file or directory)) in Unknown on line 0
I tried to install amqp library and I can't use phpize,
I tried to install php-dev and many others, it crashed in all...
I ran sudo apt install php8.1-amqp
and add new error
--show-private options doesn't exist
It be a Bug for VSCode that I 've resolved by change --show-private by --show-hidden in ~/.vscode/extensions/thenouillet.symfony-vscode-1.0.2/out/symfony/provider/ConsoleContainerProvider.js
I don't have error in the VSCode console but I have this one in my deBug Bar of Symfony:
Invalid Messenger routing configuration: the "Symfony\Component\Mailer\Messenger\SendEmailMessage" class is being routed to a sender called "amqp". This is not a valid transport or service id.

Issue while setting mailer in pimcore(symfony) :- Invalid configuration for path "framework.mailer": "dsn" and "transports" cannot be used together

Facing an issue with the mailer in pimcore 10.2 is made in symfony5.4.
Invalid configuration for path "framework.mailer": "dsn" and "transports" cannot be used together.
The setting I have done for the mail
# .env
MAILER_DSN=smtp://user:pass#smtp.example.com:port
# config/packages/mailer.yaml
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
I didn't set any other mail transport.
#### SYMFONY MAILER TRANSPORTS
# mailer:
# transports:
# main: smtp://user:pass#smtp.example.com:port
# pimcore_newsletter: smtp://user:pass#smtp.example.com:port
Error gone when I remove mailer.yaml file. But then mail is not sending.
The problem was in mailer.yaml.
It should be like
# config/packages/mailer.yaml
framework:
mailer:
transports:
main: '%env(MAILER_DSN)%'

Can you define a consumer command that only consumes a specific queue of a multi-queue transport?

I have the impression to miss something while implementing AMQP services with RabbitMQ and Symfony Messenger.
From a RabbitMQ perspective, consumers (also known as workers) consume from queues.
From the Symfony Messenger documentation, one "transport" is linked to one consumer. This is by design as shown by the command bin/console messenger:consume transport. So, for each "handler", you have to configure a dedicated transport in messenger.yaml to be able to allocate a specific number of processes (via Supervisor for instance in configuring the numprocs variable).
As stated, I found a way to configure that use case using 2 different transports. Yet, that looks a bit too complicated to me:
framework:
messenger:
transports:
one_transport:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
exchange:
name: my_exchange
type: direct
queues:
one_queue:
binding_keys:
- one_binding_key
another_transport:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
exchange:
name: my_exchange
type: direct
queues:
another_queue:
binding_keys:
- another_binding_key
routing:
'App\MessageBroker\Message\OneNotification': one_transport
'App\MessageBroker\Message\AnotherNotification': another_transport
# In action 1
$this->dispatchMessage(
new OneNotification(), [new AmqpStamp('one_binding_key')]
);
# Action 2
$this->dispatchMessage(
new AnotherNotification(), [new AmqpStamp('another_binding_key')]
);
# SF consumer 1
[program:messenger-consume]
command=php bin/console messenger:consume one_transport
numprocs=4
# SF consumer 2
[program:messenger-consume]
command=php bin/console messenger:consume another_transport
numprocs=1
No other way to achieve this?

Messenger symfony : worker has no effect

I'm building an app with symfony 4.4. I use messenger to send emails asynchronously. everything works like a charm on my computer in dev. But on my server (debian VPS) something goes wrong.
When i try to send an email, my message is handled and stored by doctrine (select * from messenger_messages returns 1 line with the message I just sent). But when i run php bin/console messenger:consume async nothing's happens. The worker starts and stay waiting as if there were no message in database.
If someone could help ...
messenger.yaml
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
async_priority_high:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
# default configuration
retry_strategy:
max_retries: 3
# milliseconds delay
delay: 1000
# causes the delay to be higher before each retry
# e.g. 1 second delay, 2 seconds, 4 seconds
multiplier: 2
max_delay: 0
# override all of this with a service that
# implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
# service: null
routing:
# Route your messages to the transports
'App\Service\Email\EmailMessage': async
.env
MESSENGER_TRANSPORT_DSN=doctrine://default
Resolved
In fact, everything was working fine but with a 1 hour delay ... Mysql and system timezone xwere different :-( !

Symfony how to use Mercure with Messenger + RabbitMQ?

I am looking to use Mercury with RabbitMQ. This is the first time that I have used Mercury as well as RabbitMQ so I am not yet good.
Here is where I am:
I've installed Mercure, and Messenger.
Messenger.yaml
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async: '%env(MESSENGER_TRANSPORT_DSN)%'
failed: '%env(MESSENGER_TRANSPORT_FAILED_DSN)%'
# sync: 'sync://'
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
.env:
MERCURE_PUBLISH_URL=http://localhost:3000/.well-known/mercure
MERCURE_JWT_TOKEN=aVerySecretKey
MESSENGER_TRANSPORT_DSN=amqp://bastien:mypassword#localhost:5672/%2f/messages
MESSENGER_TRANSPORT_FAILED_DSN=amqp://bastien:mypassword#localhost:5672/%2f/failed
And in my controller I simulated 50 pings on a URL of my local app:
/**
* #Route("/ping", name="ping", methods={"POST"})
*/
public function ping(MessageBusInterface $bus)
{
for($i=0;$i<=50;$i++)
{
$update = new Update("http://monsite.com/ping", "[]");
$bus->dispatch($update);
}
return $this->redirectToRoute('home');
}
I have successfully started my instance of Mercury as well as that of Messenger which is therefore well connected to my RabbitMQ.
But when I test sending the pings, it works, but without going through my RabbitMQ. Did I miss something? I think of my Messenger.yaml in the routing part but I don't know what to put if it is the case
By default, messages are executed synchronously in messenger.
You will need to configure the Update message in the messenger.yaml to use the async transport:
Symfony\Component\Mercure\Update: async

Resources