You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content_management/data_migration/importing_data.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ You can run a set of one or more similar migration steps multiple times by using
88
88
89
89
A repeatable migration performs the defined migration steps as many times as specified:
90
90
91
-
- with an [interation counter](#repeatable-steps-with-iteration-counter), mimicking the behavior of a [`for` loop](https://www.php.net/manual/en/control-structures.for.php)
91
+
- with an [iteration counter](#repeatable-steps-with-iteration-counter), mimicking the behavior of a [`for` loop](https://www.php.net/manual/en/control-structures.for.php)
92
92
- with a [list of items](#repeatable-steps-with-items), mimicking the behavior of a [`foreach` loop](https://www.php.net/manual/en/control-structures.foreach.php)
Copy file name to clipboardExpand all lines: docs/infrastructure_and_maintenance/background_tasks.md
+66-8Lines changed: 66 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ These messages are stored in a queue and picked up by a background worker, which
21
21
The process works as follows:
22
22
23
23
1. A message PHP object is dispatched, for example, `ProductPriceReindex`.
24
-
2. The message is wrapped in an envelope, which may contain additional metadata, called stamps, for example, `DeduplicateStamp`.
24
+
2. The message is wrapped in an envelope, which may contain additional metadata, called [stamps](#stamps).
25
25
3. The message is placed in the transport queue.
26
26
It can be a Doctrine table, a Redis/Valkey queue, and so on.
27
27
4. A worker process continuously reads messages from the queue, pulls them into the default bus `ibexa.messenger.bus` and assigns them to the right handler.
@@ -92,25 +92,83 @@ For more information, see [Symfony production recommendation for the Messenger c
92
92
93
93
If you deploy your application on [[= product_name_cloud =]], using [Workers](https://fixed.docs.upsun.com/guides/symfony/workers.html) is recommended.
94
94
95
-
###Dispatch message
95
+
## Dispatch message
96
96
97
-
Dispatch a message from your code like in the following example:
97
+
To have a task processed in the background, dispatch an appropriate message by using the `\Symfony\Component\Messenger\MessageBusInterfac\MessageBusInterface::dispatch()` method, exactly as described in [Symfony Messenger documentation]([[= symfony_doc =]]/messenger.html#dispatching-the-message):
Additionally, attach message metadata by using [stamps](#stamps).
108
+
109
+
### Stamps
110
+
111
+
You can attach [Stamps]([[= symfony_doc =]]/messenger.html#envelopes-stamps) to a message envelope to add additional metadata and control how the message is processed.
112
+
113
+
Use [Stamps available in Symfony](https://github.com/symfony/symfony/tree/[[= symfony_version =]]/src/Symfony/Component/Messenger/Stamp), and combine them with the ones provided by [[= product_name =]]:
114
+
115
+
-[SudoStamp](#sudostamp)
116
+
-[UserPermissionStamp](#userpermissionstamp)
117
+
118
+
#### SudoStamp
119
+
120
+
[`SudoStamp`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Messenger-Stamp-SudoStamp.html) causes the handler to [use sudo mode](php_api.md#using-sudo), bypassing all permission checks when processing the message.
121
+
122
+
It's automatically attached to every dispatched message.
104
123
105
-
Create the handler class:
124
+
!!! caution
125
+
126
+
Starting with Ibexa DXP 5.0.9, the behavior of automatically attaching a `SudoStamp` to every message is deprecated and will be removed in 6.0.
127
+
For messages that should be processed without taking permissions into account, always attach the `SudoStamp` manually to keep your code forward-compatible.
128
+
129
+
The following example shows how you can attach the `SudoStamp` to the message:
[`UserPermissionStamp`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Messenger-Stamp-UserPermissionStamp.html) allows you to [set the repository user](php_api.md#setting-the-repository-user) to process the message.
141
+
When the user is set, handlers execute actions on their behalf and take their permissions into account.
142
+
143
+
If you don't attach this stamp, the messages are processed by the default repository user called anonymous user.
144
+
By combing this stamp with [`SudoStamp`](#sudostamp), you can set the repository user and skip the permission checks at the same time.
145
+
146
+
The following example shows how you can use `UserPermissionStamp` to preserve the current repository user after the message is dispatched.
To handle additional use cases with background tasks, you can create [custom message and handler class]([[= symfony_doc =]]/messenger.html#creating-a-message-handler):
0 commit comments