Skip to content

Added doc for SiteAccessStamp - #3340

Open
mnocon wants to merge 7 commits into
4.6from
siteaccess-stamp
Open

Added doc for SiteAccessStamp#3340
mnocon wants to merge 7 commits into
4.6from
siteaccess-stamp

Conversation

@mnocon

@mnocon mnocon commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Documentation for ibexa/messenger#13

Turns out we didn't have the "send the message to the transport" covered - adding this as well.

One TODO left: add the missing link once PHP API reference is regenerated

mnocon added 2 commits August 4, 2026 11:23
* Described stamps for Ibexa Messenger

* Fixed typos

* Link to Symfony messages
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

@mnocon mnocon added the Wait with merge PRs that shouldn't be merged instantly label Aug 4, 2026
@mnocon
mnocon marked this pull request as ready for review August 4, 2026 14:05
Comment thread docs/infrastructure_and_maintenance/background_tasks.md Outdated

The stamp changes the configuration scope only.
It doesn't change the SiteAccess in the `Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface` service.
`SiteAccessServiceInterface::getCurrent()` always returns the SiteAccess that the worker process started with, for all messages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: Will be fixed in ibexa/core#798 / 6.0.

We could also make SiteAccessService to listen to CONFIG_SCOPE_CHANGE events in 5.x and react accordingly, and backport the stack feature from 6.0. In theory this is a bug (SiteAccessService::getCurrent() returning wrong site access), so we would not exactly break BC promise - but initially I thought we shouldn't.

@konradoboza @alongosz @ibexa/php-dev ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I understand correctly, this note can be removed in 5.0 and 6.0 when ibexa/core#805 is merged? Depending on whether it gets merged before or after the release, in this PR or in a follow-up.

Co-authored-by: Paweł Niedzielski <pawel.niedzielski@ibexa.co>
@mnocon
mnocon requested a review from a team August 11, 2026 11:44
@ibexa-workflow-automation-1
ibexa-workflow-automation-1 Bot requested review from adriendupuis, dabrt and julitafalcondusza and removed request for a team August 11, 2026 11:45
@mnocon mnocon mentioned this pull request Aug 12, 2026
7 tasks

@adriendupuis adriendupuis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a SomeMessage object isn't created and dispatched, the doc seems incomplete.
"Route message to background queue" should be more clearly mandatory and a follow up of handler creation in previous section. An handler alone doesn't sent to background tasks queue? No, you need a message provider tagged properly to forward the message to background. Maybe a little summary of the needed elements before entering into code examples?

Comment on lines +140 to +141
Use the `--siteaccess` option to set the default [SiteAccess](multisite_configuration.md#siteaccess-configuration) and [repository](repository_configuration.md#defining-custom-connection) for the worker process.
The worker uses this SiteAccess for every message that doesn't have a [`SiteAccessStamp`](#siteaccessstamp).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we hare reco about what should be the default SiteAccess?
I don't remember why I used admin in https://doc.ibexa.co/en/5.0/getting_started/install_with_ddev/#configure-background-tasks-optional

@mnocon mnocon Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Steveb-p what do you think, which SiteAccess should the worker use by default - can we recommend something?

I guess it doesn't matter, as long it's one SA per each repository configured and SiteAccess stamps are added correctly

Comment on lines +146 to +147
In [multi-repository setups](repository_configuration.md), run one worker process for each repository.
With this setup, each worker process can connect to the right database.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, which siteaccess to pick-up? A random front or the back office?

Comment thread docs/infrastructure_and_maintenance/background_tasks.md
Comment thread docs/infrastructure_and_maintenance/background_tasks.md Outdated
@mnocon

mnocon commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@adriendupuis please have a look at fe4b1b3 - I've changed the example to create a custom message, and added more info about the need for sending to transport.

@mnocon
mnocon requested a review from adriendupuis August 12, 2026 12:41
@github-actions

Copy link
Copy Markdown

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php


code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php

docs/infrastructure_and_maintenance/background_tasks.md@164:``` php
docs/infrastructure_and_maintenance/background_tasks.md@165:[[= include_code('code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php', 1, 19, remove_indent=True) =]]
docs/infrastructure_and_maintenance/background_tasks.md@166:[[= include_code('code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php', 23, 24, remove_indent=True) =]]
docs/infrastructure_and_maintenance/background_tasks.md@167:```
docs/infrastructure_and_maintenance/background_tasks.md@171:    ``` php
docs/infrastructure_and_maintenance/background_tasks.md@172: [[= include_code('code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php', 1, 5, indent_level=1) =]]
docs/infrastructure_and_maintenance/background_tasks.md@173: [[= include_code('code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php', 7, 20, indent_level=1) =]]
docs/infrastructure_and_maintenance/background_tasks.md@174: [[= include_code('code_samples/background_tasks/src/Dispatcher/SomeClassThatSchedulesExecutionInTheBackground.php', 24, 25, indent_level=1) =]]
docs/infrastructure_and_maintenance/background_tasks.md@175: ```


001⫶<?php declare(strict_types=1);
001⫶    <?php declare(strict_types=1);
002⫶
003⫶namespace App\Dispatcher;
004⫶
002⫶
003⫶namespace App\Dispatcher;
004⫶
005⫶use Ibexa\Bundle\Messenger\Stamp\DeduplicateStamp;
006⫶use Symfony\Component\Messenger\MessageBusInterface;
005⫶use App\Message\SomeMessage;
006⫶ use Symfony\Component\Messenger\MessageBusInterface;
007⫶
008⫶final class SomeClassThatSchedulesExecutionInTheBackground
009⫶{
010⫶ private MessageBusInterface $bus;
011⫶
012⫶ public function __construct(MessageBusInterface $bus)
013⫶ {
014⫶ $this->bus = $bus;
015⫶ }
016⫶
007⫶
008⫶final class SomeClassThatSchedulesExecutionInTheBackground
009⫶{
010⫶ private MessageBusInterface $bus;
011⫶
012⫶ public function __construct(MessageBusInterface $bus)
013⫶ {
014⫶ $this->bus = $bus;
015⫶ }
016⫶
017⫶    public function schedule(object $message): void
017⫶    public function schedule(): void
018⫶    {
018⫶    {
019⫶        $this->bus->dispatch($message);
020⫶ }
019⫶        $this->bus->dispatch(new SomeMessage());
020⫶ }
021⫶}


code_samples/background_tasks/src/Messenger/SomeMessageProvider.php

021⫶}


code_samples/background_tasks/src/Messenger/SomeMessageProvider.php

docs/infrastructure_and_maintenance/background_tasks.md@274:``` php hl_lines="12"
docs/infrastructure_and_maintenance/background_tasks.md@275:[[= include_file('code_samples/background_tasks/src/Messenger/SomeMessageProvider.php') =]]
docs/infrastructure_and_maintenance/background_tasks.md@276:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶namespace App\Messenger;
004⫶
005⫶use App\Message\SomeMessage;
006⫶use Ibexa\Contracts\Messenger\Transport\MessageProviderInterface;
007⫶
008⫶final class SomeMessageProvider implements MessageProviderInterface
009⫶{
010⫶ public function getHandledClasses(): iterable
011⫶ {
012❇️ return [SomeMessage::class];
013⫶ }
014⫶}

Download colorized diff

@adriendupuis adriendupuis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be nice to have an additional note about what to consider when picking up a default SiteAccess to run the background worker.
But my main previous concern is solved and this is mergeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for MERGE Wait with merge PRs that shouldn't be merged instantly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants