InMemoryTransportFactory
creates theInMemoryTransport
with a clock (if configured in the factory)- Add option
redis_sentinel
as an alias forsentinel_master
- Add
--all
option to themessenger:consume
command - Add parameter
$jitter
toMultiplierRetryStrategy
in order to randomize delay and prevent the thundering herd effect - Add
SIGQUIT
signal among list of signals that gracefully shut downmessenger:consume
andmessenger:failed:retry
commands - Add
EnvelopeAwareExceptionInterface
for exceptions thrown from middlewares to prevent stamps added by previous middlewares being dropped
- Add parameter
$isSameDatabase
toDoctrineTransport::configureSchema()
- Remove
MessageHandlerInterface
andMessageSubscriberInterface
, use#[AsMessageHandler]
instead - Remove
StopWorkerOnSigtermSignalListener
in favor of using theSignalableCommandInterface
- Remove
StopWorkerOnSignalsListener
in favor of using theSignalableCommandInterface
- Remove
Symfony\Component\Messenger\Transport\InMemoryTransport
andSymfony\Component\Messenger\Transport\InMemoryTransportFactory
in favor ofSymfony\Component\Messenger\Transport\InMemory\InMemoryTransport
andSymfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory
- Remove
HandlerFailedException::getNestedExceptions()
,HandlerFailedException::getNestedExceptionsOfClass()
andDelayedMessageHandlingException::getExceptions()
which are replaced by a newgetWrappedExceptions()
method
- Deprecate
StopWorkerOnSignalsListener
in favor of using theSignalableCommandInterface
- Add
HandlerDescriptor::getOptions
- Add support for multiple Redis Sentinel hosts
- Add
--all
option to themessenger:failed:remove
command - Add
WrappedExceptionsInterface
interface for exceptions that hold multiple individual exceptions - Deprecate
HandlerFailedException::getNestedExceptions()
,HandlerFailedException::getNestedExceptionsOfClass()
andDelayedMessageHandlingException::getExceptions()
which are replaced by a newgetWrappedExceptions()
method
- Add support for namespace wildcards in the HandlersLocator to allow routing multiple messages within the same namespace
- Deprecate
Symfony\Component\Messenger\Transport\InMemoryTransport
andSymfony\Component\Messenger\Transport\InMemoryTransportFactory
in favor ofSymfony\Component\Messenger\Transport\InMemory\InMemoryTransport
andSymfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory
- Allow passing a string instead of an array in
TransportNamesStamp
- Allow to define batch size when using
BatchHandlerTrait
withgetBatchSize()
- Deprecate
StopWorkerOnSigtermSignalListener
in favor ofStopWorkerOnSignalsListener
and make it configurable with SIGINT and SIGTERM by default - Add
RedispatchMessage
andRedispatchMessageHandler
- Add optional parameter
$isSameDatabase
toDoctrineTransport::configureSchema()
- Add new
messenger:stats
command that returns a list of transports with their "to be processed" message count - Add
TransportNamesStamp
to change the transport while dispatching a message - Add support for rate limited transports by using the RateLimiter component.
- Deprecate
MessageHandlerInterface
andMessageSubscriberInterface
, use#[AsMessageHandler]
instead - Add new parameter
allowNoSenders
toSendMessageMiddleware
to enable throwing when a message doesn't have a sender
- Add
SerializedMessageStamp
to avoid serializing a message when a retry occurs - Automatically resolve handled message type when method different from
__invoke
is used as handler - Allow
#[AsMessageHandler]
attribute on methods
- Remove deprecated classes
Symfony/Component/Messenger/Transport/AmqpExt
,Symfony/Component/Messenger/Transport/Doctrine
andSymfony/Component/Messenger/Transport/Redis
. - Class
MessengerPass
cannot be configured with constructor arguments - Remove constructor arguments and getters for
RedeliveryStamp
's propertiesexceptionMessage
andflattenException
- Add
AsMessageHandler
attribute for declaring message handlers on PHP 8. - Add support for handling messages in batches with
BatchHandlerInterface
and corresponding trait - Add
StopWorkerExceptionInterface
and its implementationStopWorkerException
to stop the worker. - Add support for resetting container services after each messenger message.
- Added
WorkerMetadata
class which allows you to access the configuration details of a worker, likequeueNames
andtransportNames
it consumes from. - New method
getMetadata()
was added toWorker
class which returns theWorkerMetadata
object. - Deprecate not setting the
reset_on_message
config option, its default value will change totrue
in 6.0 - Add log when worker should stop.
- Add log when
SIGTERM
is received. - Add
--stats
and--class-filter
options toFailedMessagesShowCommand
- Add the
RouterContextMiddleware
to restore the original router context when handling a message InMemoryTransport
can perform message serialization through dsnin-memory://?serialize=true
.- Added
queues
option toWorker
to only fetch messages from a specific queue from a receiver implementingQueueReceiverInterface
.
- The
RedeliveryStamp
will no longer be populated with error data. This information is now stored in theErrorDetailsStamp
instead. - Added
FlattenExceptionNormalizer
to give more information about the exception on Messenger background processes. TheFlattenExceptionNormalizer
has a higher priority thanProblemNormalizer
and it is only used when the Messenger serialization context is set. - Added factory methods
DelayStamp::delayFor(\DateInterval)
andDelayStamp::delayUntil(\DateTimeInterface)
. - Removed the exception when dispatching a message with a
DispatchAfterCurrentBusStamp
and not in a context of another dispatch call - Added
WorkerMessageRetriedEvent
- Moved AmqpExt transport to package
symfony/amqp-messenger
. All classes inSymfony\Component\Messenger\Transport\AmqpExt
have been moved toSymfony\Component\Messenger\Bridge\Amqp\Transport
- Moved Doctrine transport to package
symfony/doctrine-messenger
. All classes inSymfony\Component\Messenger\Transport\Doctrine
have been moved toSymfony\Component\Messenger\Bridge\Doctrine\Transport
- Moved RedisExt transport to package
symfony/redis-messenger
. All classes inSymfony\Component\Messenger\Transport\RedisExt
have been moved toSymfony\Component\Messenger\Bridge\Redis\Transport
- Added support for passing a
\Throwable
argument toRetryStrategyInterface
methods. This allows to define strategies based on the reason of the handling failure. - Added
StopWorkerOnFailureLimitListener
to stop the worker after a specified amount of failed messages is reached. - Added
RecoverableExceptionInterface
interface to force retry.
- The
LoggingMiddleware
class has been removed, pass a logger toSendMessageMiddleware
instead. - made
SendersLocator
require aContainerInterface
as 2nd argument
- Added support for auto trimming of Redis streams.
InMemoryTransport
handle acknowledged and rejected messages.- Made all dispatched worker event classes final.
- Added support for
from_transport
attribute onmessenger.message_handler
tag. - Added support for passing
dbindex
as a query parameter to the redis transport DSN. - Added
WorkerStartedEvent
andWorkerRunningEvent
- [BC BREAK] Removed
SendersLocatorInterface::getSenderByAlias
added in 4.3. - [BC BREAK] Removed
$retryStrategies
argument fromWorker::__construct
. - [BC BREAK] Changed arguments of
ConsumeMessagesCommand::__construct
. - [BC BREAK] Removed
$senderClassOrAlias
argument fromRedeliveryStamp::__construct
. - [BC BREAK] Removed
UnknownSenderException
. - [BC BREAK] Removed
WorkerInterface
. - [BC BREAK] Removed
$onHandledCallback
ofWorker::run(array $options = [], callable $onHandledCallback = null)
. - [BC BREAK] Removed
StopWhenMemoryUsageIsExceededWorker
in favor ofStopWorkerOnMemoryLimitListener
. - [BC BREAK] Removed
StopWhenMessageCountIsExceededWorker
in favor ofStopWorkerOnMessageLimitListener
. - [BC BREAK] Removed
StopWhenTimeLimitIsReachedWorker
in favor ofStopWorkerOnTimeLimitListener
. - [BC BREAK] Removed
StopWhenRestartSignalIsReceived
in favor ofStopWorkerOnRestartSignalListener
. - The component is not marked as
@experimental
anymore. - Marked the
MessengerDataCollector
class as@final
. - Added support for
DelayStamp
to theredis
transport.
- Added
NonSendableStampInterface
that a stamp can implement if it should not be sent to a transport. Transport serializers must now check for these stamps and not encode them. - [BC BREAK]
SendersLocatorInterface
has an additional method:getSenderByAlias()
. - Removed argument
?bool &$handle = false
fromSendersLocatorInterface::getSenders
- A new
ListableReceiverInterface
was added, which a receiver can implement (when applicable) to enable listing and fetching individual messages by id (used in the new "Failed Messages" commands). - Both
SenderInterface::send()
andReceiverInterface::get()
should now (when applicable) add aTransportMessageIdStamp
. - Added
WorkerStoppedEvent
dispatched when a worker is stopped. - Added optional
MessageCountAwareInterface
that receivers can implement to give information about how many messages are waiting to be processed. - [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
to explicitly handle messages synchronously. - Added
AmqpStamp
allowing to provide a routing key, flags and attributes on message publishing. - [BC BREAK] Removed publishing with a
routing_key
option from queue configuration, for AMQP. Use exchangedefault_publish_routing_key
orAmqpStamp
instead. - [BC BREAK] Changed the
queue
option in the AMQP transport DSN to bequeues[name]
. You can therefore name the queue but also configurebinding_keys
,flags
andarguments
. - [BC BREAK] The methods
get
,ack
,nack
andqueue
of the AMQPConnection
have a new argument: the queue name. - 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) - [BC BREAK] The
getConnectionConfiguration
method on Amqp'sConnection
has been removed. - [BC BREAK] A
HandlerFailedException
exception will be thrown if one or more handler fails. - [BC BREAK] The
HandlersLocationInterface::getHandlers
method needs to returnHandlerDescriptor
instances instead of callables. - [BC BREAK] The
HandledStamp
stamp has changed:handlerAlias
has been renamed tohandlerName
,getCallableName
has been removed and its constructor only has 2 arguments now. - [BC BREAK] The
ReceivedStamp
needs to exposes the name of the transport from which the message has been received.
- 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()
- Introduced the component as experimental