Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fbabde

Browse files
committed
[Messenger] Add more notes about base concepts, envelope items & class refs
1 parent0604511 commit9fbabde

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

‎components/messenger.rst‎

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ Concepts
4343

4444
**Handler**:
4545
Responsible for handling messages using the business logic applicable to the messages.
46+
Handlers are called by the ``HandleMessageMiddleware`` middleware.
47+
48+
**Middleware**:
49+
Middleware can access the message and its wrapper (the envelope) while it is
50+
dispatched through the bus.
51+
Literally *"the software in the middle"*, those are not about core concerns
52+
(business logic) of an application. Instead, they are cross cutting concerns
53+
applicable throughout the application and affecting the entire message bus.
54+
For instance: logging, validating a message, starting a transaction, ...
55+
They are also responsible for calling the next middleware in the chain,
56+
which means they can tweak the envelope, by adding items to it or even
57+
replacing it, as well as interrupt the middleware chain.
58+
59+
**Envelope**
60+
Messenger specific concept, it gives full flexibility inside the message bus,
61+
by wrapping the messages into it, allowing to add useful information inside
62+
through *envelope items*.
63+
64+
**Envelope Items**
65+
Piece of information you need to attach to your message: serializer context
66+
to use for transport, markers identifying a received message or any sort of
67+
metadata your middleware or transport layer may use.
4668

4769
Bus
4870
---
@@ -53,9 +75,9 @@ middleware stack. The component comes with a set of middleware that you can use.
5375
When using the message bus with Symfony's FrameworkBundle, the following middleware
5476
are configured for you:
5577

56-
#.``LoggingMiddleware`` (logs the processing of your messages)
57-
#.``SendMessageMiddleware`` (enables asynchronous processing)
58-
#.``HandleMessageMiddleware`` (calls the registered handler)
78+
#.:class:`Symfony\\Component\\Messenger\\Middleware\\LoggingMiddleware` (logs the processing of your messages)
79+
#.:class:`Symfony\\Component\\Messenger\\Asynchronous\\Middleware\\SendMessageMiddleware` (enables asynchronous processing)
80+
#.:class:`Symfony\\Component\\Messenger\\Middleware\\HandleMessageMiddleware` (calls the registered handler(s))
5981

6082
Example::
6183

@@ -74,7 +96,7 @@ Example::
7496

7597
..note::
7698

77-
Every middleware needs to implement the``MiddlewareInterface``.
99+
Every middleware needs to implement the:class:`Symfony\\Component\\Messenger\\Middleware\\MiddlewareInterface`.
78100

79101
Handlers
80102
--------
@@ -112,7 +134,7 @@ the ``SerializerConfiguration`` envelope::
112134
]))
113135
);
114136

115-
At the moment, the Symfony Messenger has the following built-inenvelopes:
137+
At the moment, the Symfony Messenger has the following built-inenvelope items:
116138

117139
#.:class:`Symfony\\Component\\Messenger\\Transport\\Serialization\\SerializerConfiguration`,
118140
to configure the serialization groups used by the transport.
@@ -151,6 +173,12 @@ The above example will forward the message to the next middleware with an additi
151173
envelope item *if* the message has just been received (i.e. has the `ReceivedMessage` item).
152174
You can create your own items by implementing:class:`Symfony\\Component\\Messenger\\EnvelopeAwareInterface`.
153175

176+
..note::
177+
178+
Any envelope item must be php serializable if going through transport using
179+
the:class:`Symfony\\Component\\Messenger\\Transport\\Serialization\\Serializer`
180+
base serializer.
181+
154182
Transports
155183
----------
156184

@@ -160,7 +188,8 @@ transport will be responsible for communicating with your message broker or 3rd
160188
Your own Sender
161189
~~~~~~~~~~~~~~~
162190

163-
Using the ``SenderInterface``, you can create your own message sender.
191+
Using the:class:`Symfony\\Component\\Messenger\\Transport\\SenderInterface`,
192+
you can create your own message sender.
164193
Imagine that you already have an ``ImportantAction`` message going through the
165194
message bus and being handled by a handler. Now, you also want to send this
166195
message as an email.

‎messenger.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ within the buses to add some extra capabilities like this:
656656
),
657657
));
658658
659-
Note that if the service is abstract, a different instance of service will be
660-
created per bus.
659+
Note that if the service is abstract, a different instance oftheservice will
660+
becreated per bus.
661661

662662
Using Middleware Factories
663663
~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp