343d28e3d1
This PR was squashed before being merged into the 4.3-dev branch (closes #30754).
Discussion
----------
[Messenger] New messenger:stop-workers Command
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | Kinda of #29451
| License | MIT
| Doc PR | symfony/symfony-docs#11236
o/ me again.
This requires and is built on top of #30708
When you deploy, all workers need to be stopped and restarted. That's not currently possible, unless you manually track the pids and send a SIGTERM signal. We can make that much easier :).
Now run:
```
bin/console messenger:stop-workers
```
And it will signal to all workers (even if they're distributed on other servers) that they should stop, once they finish processing their current message. This is done via a key in `cache.app`.
Cheers!
Commits
-------
58971627f5
[Messenger] New messenger:stop-workers Command
7.1 KiB
7.1 KiB
CHANGELOG
4.3.0
- [BC BREAK] The
Envelope::__construct()
signature changed: you can no longer pass an unlimited number of stamps as the second, third, fourth, arguments etc: stamps are now an array passed to the second argument. - [BC BREAK] The
MessageBusInterface::dispatch()
signature changed: a second argumentarray $stamps = []
was added. - Added new
messenger:stop-workers
command that sends a signal to stop allmessenger:consume
workers. - [BC BREAK] The
TransportFactoryInterface::createTransport()
signature changed: a required 3rdSerializerInterface
argument was added. - Added a new
SyncTransport
along withForceCallHandlersStamp
to explicitly handle messages synchronously. - Added optional parameter
prefetch_count
in connection configuration, to setup channel prefetch count. - New classes:
RoutableMessageBus
,AddBusNameStampMiddleware
andBusNameStamp
were added, which allow you to add a bus identifier to theEnvelope
then find the correct bus when receiving from the transport. SeeConsumeMessagesCommand
. - The optional
$busNames
constructor argument of the classConsumeMessagesCommand
was removed. - [BC BREAK] 3 new methods were added to
ReceiverInterface
:ack()
,reject()
andget()
. The methodsreceive()
andstop()
were removed. - [BC BREAK] Error handling was moved from the receivers into
Worker
. Implementations ofReceiverInterface::handle()
should now allow all exceptions to be thrown, except for transport exceptions. They should also not retry (e.g. if there's a queue, remove from the queue) if there is a problem decoding the message. - [BC BREAK]
RejectMessageExceptionInterface
was removed and replaced bySymfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException
, which has the same behavior: a message will not be retried - The default command name for
ConsumeMessagesCommand
was changed frommessenger:consume-messages
tomessenger:consume
ConsumeMessagesCommand
has two new optional constructor arguments- [BC BREAK] The first argument to Worker changed from a single
ReceiverInterface
to an array ofReceiverInterface
. Worker
has 3 new optional constructor arguments.- The
Worker
class now handles callingpcntl_signal_dispatch()
the receiver no longer needs to call this. - The
AmqpSender
will now retry messages using a dead-letter exchange and delayed queues, instead of retrying vianack()
- Senders now receive the
Envelope
with theSentStamp
on it. Previously, theEnvelope
was passed to the sender and then theSentStamp
was added. SerializerInterface
implementations should now throw aSymfony\Component\Messenger\Exception\MessageDecodingFailedException
ifdecode()
fails for any reason.- [BC BREAK] The default
Serializer
will now throw aMessageDecodingFailedException
ifdecode()
fails, instead of the underlying exceptions from the Serializer component. - Added
PhpSerializer
which uses PHP's nativeserialize()
andunserialize()
to serialize messages to a transport - [BC BREAK] If no serializer were passed, the default serializer
changed from
Serializer
toPhpSerializer
insideAmqpReceiver
,AmqpSender
,AmqpTransport
andAmqpTransportFactory
. - Added
TransportException
to mark an exception transport-related - [BC BREAK] If listening to exceptions while using
AmqpSender
orAmqpReceiver
,\AMQPException
is no longer thrown in favor ofTransportException
. - Deprecated
LoggingMiddleware
, pass a logger toSendMessageMiddleware
instead. - [BC BREAK]
Connection::__construct()
andConnection::fromDsn()
both no longer have$isDebug
arguments. - [BC BREAK] The Amqp Transport now automatically sets up the exchanges
and queues by default. Previously, this was done when in "debug" mode
only. Pass the
auto_setup
connection option to control this. - Added a
SetupTransportsCommand
command to setup the transports - Added a Doctrine transport. For example, use the
doctrine://default
DSN (this uses thedefault
Doctrine entity manager)
4.2.0
- Added
HandleTrait
leveraging a message bus instance to return a single synchronous message handling result - Added
HandledStamp
&SentStamp
stamps - All the changes below are BC BREAKS
- Senders and handlers subscribing to parent interfaces now receive all matching messages, wildcard included
MessageBusInterface::dispatch()
,MiddlewareInterface::handle()
andSenderInterface::send()
returnEnvelope
MiddlewareInterface::handle()
now require anEnvelope
as first argument and aStackInterface
as secondEnvelopeAwareInterface
has been removed- The signature of
Amqp*
classes changed to take aConnection
as a first argument and an optionalSerializer
as a second argument. MessageSubscriberInterface::getHandledMessages()
return value has changed. The value of an array item needs to be an associative array or the method name.StampInterface
replacesEnvelopeItemInterface
and doesn't extendSerializable
anymore- The
ConsumeMessagesCommand
class now takes an instance ofPsr\Container\ContainerInterface
as first constructor argument - The
EncoderInterface
andDecoderInterface
have been replaced by a unifiedSymfony\Component\Messenger\Transport\Serialization\SerializerInterface
. - Renamed
EnvelopeItemInterface
toStampInterface
Envelope
's constructor andwith()
method now acceptStampInterface
objects as variadic parameters- Renamed and moved
ReceivedMessage
,ValidationConfiguration
andSerializerConfiguration
in theStamp
namespace - Removed the
WrapIntoReceivedMessage
class MessengerDataCollector::getMessages()
returns an iterable, not just an array anymoreHandlerLocatorInterface::resolve()
has been removed, useHandlersLocator::getHandlers()
insteadSenderLocatorInterface::getSenderForMessage()
has been removed, useSendersLocator::getSenders()
instead- Classes in the
Middleware\Enhancers
sub-namespace have been moved to theMiddleware
one - Classes in the
Asynchronous\Routing
sub-namespace have been moved to theTransport\Sender\Locator
sub-namespace - The
Asynchronous/Middleware/SendMessageMiddleware
class has been moved to theMiddleware
namespace SenderInterface
has been moved to theTransport\Sender
sub-namespace- The
ChainHandler
andChainSender
classes have been removed ReceiverInterface
and its implementations have been moved to theTransport\Receiver
sub-namespaceActivationMiddlewareDecorator
has been renamedActivationMiddleware
AllowNoHandlerMiddleware
has been removed in favor of a new constructor argument onHandleMessageMiddleware
- The
ContainerHandlerLocator
,AbstractHandlerLocator
,SenderLocator
andAbstractSenderLocator
classes have been removed Envelope::all()
takes a new optional$stampFqcn
argument and returns the stamps for the specified FQCN, or all stamps by their class nameEnvelope::get()
has been renamedEnvelope::last()
4.1.0
- Introduced the component as experimental