8000 [Messenger] Add a middleware that wraps all handlers in one Doctrine transaction. by Nyholm · Pull Request #26647 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Add a middleware that wraps all handlers in one Doctrine transaction. #26647

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding configuration definition
  • Loading branch information
Nyholm committed Mar 27, 2018
commit 0261a51f9cc17c71e0820f8807b43f5e047a828f
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<xsd:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
<xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
</xsd:choice>

<xsd:attribute name="http-method-override" type="xsd:boolean" />
Expand Down Expand Up @@ -342,4 +343,32 @@
</xsd:extension>
</xsd:simpleContent 8000 >
</xsd:complexType>

<xsd:complexType name="messenger">
<xsd:all>
<xsd:element name="routing" type="messenger_routing" minOccurs="0" maxOccurs="1" />
<xsd:element name="doctrine-transaction" type="messenger_doctrine_transaction" minOccurs="0" maxOccurs="1" />
</xsd:all>
</xsd:complexType>

<xsd:complexType name="messenger_routing">
<xsd:sequence>
<xsd:element name="sender" type="messenger_routing_sender" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="messenger_routing_sender">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="message-class" type="xsd:string" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="messenger_doctrine_transaction">
<xsd:sequence>
<xsd:element name="entity-manager-name" type="xsd:string" />
Copy link
Member

Choose a reason for hiding this comment

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

this one could be an attribute rather than a child element IMO

Copy link
Member Author
@Nyholm Nyholm Mar 26, 2018

Choose a reason for hiding this comment

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

Could you please assist me here? I've had a hard time making this work. That is why the tests are failing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Contributor

Choose a reason for hiding this comment

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

Last thing I guess: can you move this to be an attribute? It would mean this XML would look like that instead:

    <framework:config>
        <framework:messenger>
            <framework:doctrine-transaction entity-manager-name="foobar" />
        </framework:messenger>
    </framework:config>

</xsd:sequence>
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>
</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

$container->loadFromExtension('framework', array(
'messenger' => array(
'enabled' => true,
'routing' => [
'App\Foo' => 'sender.foo',
'App\Bar' => 'sender.bar',
],
),
));
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:messenger>
<framework:routing>
<framework:sender message-class="App\Foo">sender.foo</framework:sender>
<framework:sender message-class="App\Bar">sender.bar</framework:sender>
</framework:routing>
</framework:messenger>
</framework:config>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<framework:config>
<framework:messenger>
<framework:doctrine-transaction >
<framework:doctrine-transaction>
<framework:entity-manager-name>foobar</framework:entity-manager-name>
</framework:doctrine-transaction>
</framework:messenger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
framework:
messenger: ~
messenger:
routing:
'App\Foo': 'sender.foo'
'App\Bar': 'sender.bar'
0