bug #39674 [Messenger] fix postgres transport when the retry table is the same (lyrixx)

This PR was merged into the 5.1 branch.

Discussion
----------

[Messenger] fix postgres transport when the retry table is the same

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

---

I noticed messenger do not consume all messages when there is a retry
and when I'm using only one table for everything.

To reproduce, use the following configuration + use PG + throw an
exception in the handler

```yaml
framework:
    messenger:
        failure_transport: failed

        transports:
            async: '%env(MESSENGER_TRANSPORT_DSN)%'
            failed: 'doctrine://default?queue_name=failed'

        routing:
            'App\Message\Foobar': async
```

The real issue is PG does not notify messenger when we `UPDATE` the message.

---

ping @dunglas

Commits
-------

2b4d47163f fix postgres transport when the retry table is the same
This commit is contained in:
Fabien Potencier 2021-01-01 10:40:53 +01:00
commit e6ba3a5e4b

View File

@ -123,7 +123,7 @@ SQL
, $this->configuration['table_name']),
// register trigger
sprintf('DROP TRIGGER IF EXISTS notify_trigger ON %s;', $this->configuration['table_name']),
sprintf('CREATE TRIGGER notify_trigger AFTER INSERT ON %1$s FOR EACH ROW EXECUTE PROCEDURE notify_%1$s();', $this->configuration['table_name']),
sprintf('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON %1$s FOR EACH ROW EXECUTE PROCEDURE notify_%1$s();', $this->configuration['table_name']),
'COMMIT;',
];
}