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

[Messenger] Describe the doctrine transport#10616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@vincenttouzet
Copy link
Contributor

@vincenttouzetvincenttouzet commentedOct 30, 2018
edited
Loading

Add documentation relative to the PRsymfony/symfony#29007

TODO

@vincenttouzetvincenttouzet changed the title[Messenger] Describe the doctrine tranport[Messenger] Describe the doctrine transportOct 30, 2018
@vincenttouzetvincenttouzetforce-pushed themessenger-doctrine-transport branch from5a19dd2 to9bbc360CompareNovember 11, 2018 15:32
@vincenttouzetvincenttouzetforce-pushed themessenger-doctrine-transport branch 2 times, most recently frombca4f9b toec267d1CompareMarch 25, 2019 19:24
symfony-splitter pushed a commit to symfony/messenger that referenced this pull requestMar 31, 2019
This PR was merged into the 4.3-dev branch.Discussion----------[Messenger] Add a Doctrine transport| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |symfony/symfony-docs#10616| DoctrineBundle PR |doctrine/DoctrineBundle#868As discussed with@sroze at PHPForum in Paris I've worked on adding a Doctrine transport to the Messenger component.Actually `AMQP` is the only supported transport and it could be a good thing to support multiple transports. Having a Doctrine transport could help users to start using the component IMHO (Almost all projects use a database).# How it worksThe code is splitted betwwen this PR and the one on the DoctrineBundle :doctrine/DoctrineBundle#868## ConfigurationTo configure a Doctrine transport the dsn MUST have the format `doctrine://<entity_manager_name>` where `<entity_manager_name>` is the name of the entity manager (usually `default`)```yml        # config/packages/messenger.yaml        framework:            messenger:                transports:                    my_transport: "doctrine://default?queue=important"```## Table schemaDispatched messages are stored into a database table with the following schema:| Column       | Type     | Options                  | Description                                                       ||--------------|----------|--------------------------|-------------------------------------------------------------------|| id           | bigint   | AUTO_INCREMENT, NOT NULL | Primary key                                                       || body         | text     | NOT NULL                 | Body of the message                                               || headers      | text     | NOT NULL                 | Headers of the message                                            || queue      | varchar(32)     | NOT NULL                 | Headers of the message                                            || created_at   | datetime | NOT NULL                 | When the message was inserted onto the table. (automatically set) || available_at       | datetime   | NOT NULL                 | When the message is available to be handled                      || delivered_at | datetime | NULL                     | When the message was delivered to a worker                        |## Message dispatchingWhen dispatching a message a new row is inserted into the table. See `Symfony\Component\Messenger\Transport\Doctrine::publish`## Message consumingThe message is retrieved by the `Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceiver`. It calls the `Symfony\Component\Messenger\Transport\Doctrine::get` method to get the next message to handle.### Getting the next message* Start a transaction* Lock the table to get the first message to handle (The lock is done with the `SELECT ... FOR UPDATE` query)* Update the message in database to update the delivered_at columns* Commit the transaction### Handling the messageThe retrieved message is then passed to the handler. If the message is correctly handled the receiver call the `Symfony\Component\Messenger\Transport\Doctrine::ack` which delete the message from the table.If an error occured the receiver call the `Symfony\Component\Messenger\Transport\Doctrine::nack` method which update the message to set the delivered_at column to `null`.## Message requeueingIt may happen that a message is stuck in `delivered` state but the handler does not really handle the message (Database connection error, server crash, ...). To requeue messages the `DoctrineReceiver` call the `Symfony\Component\Messenger\Transport\Doctrine::requeueMessages`. This method update all the message with a  `delivered_at` not null since more than the "redeliver timeout" (default to 3600 seconds)# TODO- [x] Add tests- [x] Create DOC PR- [x] PR on doctrine-bundle for transport factory- [x] Add a `available_at` column- [x] Add a `queue` column- [x] Implement the retry functionnality : See #30557- [x] Rebase after #29476Commits-------88d008c828 [Messenger] Add a Doctrine transport
sroze added a commit to symfony/symfony that referenced this pull requestMar 31, 2019
This PR was merged into the 4.3-dev branch.Discussion----------[Messenger] Add a Doctrine transport| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |symfony/symfony-docs#10616| DoctrineBundle PR |doctrine/DoctrineBundle#868As discussed with@sroze at PHPForum in Paris I've worked on adding a Doctrine transport to the Messenger component.Actually `AMQP` is the only supported transport and it could be a good thing to support multiple transports. Having a Doctrine transport could help users to start using the component IMHO (Almost all projects use a database).# How it worksThe code is splitted betwwen this PR and the one on the DoctrineBundle :doctrine/DoctrineBundle#868## ConfigurationTo configure a Doctrine transport the dsn MUST have the format `doctrine://<entity_manager_name>` where `<entity_manager_name>` is the name of the entity manager (usually `default`)```yml        # config/packages/messenger.yaml        framework:            messenger:                transports:                    my_transport: "doctrine://default?queue=important"```## Table schemaDispatched messages are stored into a database table with the following schema:| Column       | Type     | Options                  | Description                                                       ||--------------|----------|--------------------------|-------------------------------------------------------------------|| id           | bigint   | AUTO_INCREMENT, NOT NULL | Primary key                                                       || body         | text     | NOT NULL                 | Body of the message                                               || headers      | text     | NOT NULL                 | Headers of the message                                            || queue      | varchar(32)     | NOT NULL                 | Headers of the message                                            || created_at   | datetime | NOT NULL                 | When the message was inserted onto the table. (automatically set) || available_at       | datetime   | NOT NULL                 | When the message is available to be handled                      || delivered_at | datetime | NULL                     | When the message was delivered to a worker                        |## Message dispatchingWhen dispatching a message a new row is inserted into the table. See `Symfony\Component\Messenger\Transport\Doctrine::publish`## Message consumingThe message is retrieved by the `Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceiver`. It calls the `Symfony\Component\Messenger\Transport\Doctrine::get` method to get the next message to handle.### Getting the next message* Start a transaction* Lock the table to get the first message to handle (The lock is done with the `SELECT ... FOR UPDATE` query)* Update the message in database to update the delivered_at columns* Commit the transaction### Handling the messageThe retrieved message is then passed to the handler. If the message is correctly handled the receiver call the `Symfony\Component\Messenger\Transport\Doctrine::ack` which delete the message from the table.If an error occured the receiver call the `Symfony\Component\Messenger\Transport\Doctrine::nack` method which update the message to set the delivered_at column to `null`.## Message requeueingIt may happen that a message is stuck in `delivered` state but the handler does not really handle the message (Database connection error, server crash, ...). To requeue messages the `DoctrineReceiver` call the `Symfony\Component\Messenger\Transport\Doctrine::requeueMessages`. This method update all the message with a  `delivered_at` not null since more than the "redeliver timeout" (default to 3600 seconds)# TODO- [x] Add tests- [x] Create DOC PR- [x] PR on doctrine-bundle for transport factory- [x] Add a `available_at` column- [x] Add a `queue` column- [x] Implement the retry functionnality : See#30557- [x] Rebase after#29476Commits-------88d008c [Messenger] Add a Doctrine transport
@vincenttouzetvincenttouzetforce-pushed themessenger-doctrine-transport branch fromec267d1 to4f4ac88CompareMarch 31, 2019 17:25
@alexander-schranz
Copy link
Contributor

alexander-schranz commentedApr 7, 2019
edited
Loading

Should we create for each transport a own documentation file?

In this case we should also create a documentation file about the amqp implementation.
And make a list inhttps://symfony.com/doc/current/messenger.html#transports

/cc@sroze

#EU-FOSSA

@vincenttouzetvincenttouzetforce-pushed themessenger-doctrine-transport branch from4f4ac88 to5d9686cCompareApril 9, 2019 11:21
@vincenttouzetvincenttouzetforce-pushed themessenger-doctrine-transport branch 3 times, most recently from90f9fd8 to322955dCompareApril 9, 2019 11:24
@vincenttouzetvincenttouzetforce-pushed themessenger-doctrine-transport branch from322955d to4e65148CompareApril 9, 2019 14:08
@weaverryan
Copy link
Member

Thank you Vincent for this great feature and its docs!

symfony-splitter pushed a commit to symfony/messenger that referenced this pull requestJan 28, 2020
This PR was merged into the 4.3-dev branch.Discussion----------[Messenger] Add a Doctrine transport| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |symfony/symfony-docs#10616| DoctrineBundle PR |doctrine/DoctrineBundle#868As discussed with@sroze at PHPForum in Paris I've worked on adding a Doctrine transport to the Messenger component.Actually `AMQP` is the only supported transport and it could be a good thing to support multiple transports. Having a Doctrine transport could help users to start using the component IMHO (Almost all projects use a database).# How it worksThe code is splitted betwwen this PR and the one on the DoctrineBundle :doctrine/DoctrineBundle#868## ConfigurationTo configure a Doctrine transport the dsn MUST have the format `doctrine://<entity_manager_name>` where `<entity_manager_name>` is the name of the entity manager (usually `default`)```yml        # config/packages/messenger.yaml        framework:            messenger:                transports:                    my_transport: "doctrine://default?queue=important"```## Table schemaDispatched messages are stored into a database table with the following schema:| Column       | Type     | Options                  | Description                                                       ||--------------|----------|--------------------------|-------------------------------------------------------------------|| id           | bigint   | AUTO_INCREMENT, NOT NULL | Primary key                                                       || body         | text     | NOT NULL                 | Body of the message                                               || headers      | text     | NOT NULL                 | Headers of the message                                            || queue      | varchar(32)     | NOT NULL                 | Headers of the message                                            || created_at   | datetime | NOT NULL                 | When the message was inserted onto the table. (automatically set) || available_at       | datetime   | NOT NULL                 | When the message is available to be handled                      || delivered_at | datetime | NULL                     | When the message was delivered to a worker                        |## Message dispatchingWhen dispatching a message a new row is inserted into the table. See `Symfony\Component\Messenger\Transport\Doctrine::publish`## Message consumingThe message is retrieved by the `Symfony\Component\Messenger\Transport\Doctrine\DoctrineReceiver`. It calls the `Symfony\Component\Messenger\Transport\Doctrine::get` method to get the next message to handle.### Getting the next message* Start a transaction* Lock the table to get the first message to handle (The lock is done with the `SELECT ... FOR UPDATE` query)* Update the message in database to update the delivered_at columns* Commit the transaction### Handling the messageThe retrieved message is then passed to the handler. If the message is correctly handled the receiver call the `Symfony\Component\Messenger\Transport\Doctrine::ack` which delete the message from the table.If an error occured the receiver call the `Symfony\Component\Messenger\Transport\Doctrine::nack` method which update the message to set the delivered_at column to `null`.## Message requeueingIt may happen that a message is stuck in `delivered` state but the handler does not really handle the message (Database connection error, server crash, ...). To requeue messages the `DoctrineReceiver` call the `Symfony\Component\Messenger\Transport\Doctrine::requeueMessages`. This method update all the message with a  `delivered_at` not null since more than the "redeliver timeout" (default to 3600 seconds)# TODO- [x] Add tests- [x] Create DOC PR- [x] PR on doctrine-bundle for transport factory- [x] Add a `available_at` column- [x] Add a `queue` column- [x] Implement the retry functionnality : See #30557- [x] Rebase after #29476Commits-------88d008c828 [Messenger] Add a Doctrine transport
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark requested changes

+1 more reviewer

@magnusnordlandermagnusnordlandermagnusnordlander left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@vincenttouzet@alexander-schranz@weaverryan@magnusnordlander@nicolas-grekas@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp