sroze / messenger-enqueue-transport

Uses Enqueue with Symfony's Messenger component.
MIT License
191 stars 55 forks source link

Fixing serialization problems with ObjectNormalizer + more helpers #48

Closed weaverryan closed 5 years ago

weaverryan commented 5 years ago

The TransportConfiguration is currently broken for default Messenger installs because the default install uses the ObjectNormalizer for serialization, which causes several problems:

I've re-worked this class to play nicely with the ObjectNormalizer. AND, I've added methods for the most common options/methods that you'll want to configure on your message. This makes the experience a bit nicer, while still making the old way work

// before (still works)
$envelope = (new Envelope($message))
    ->with(new TransportConfiguration(['metadata' => [
        'deliveryDelay' => 10000
    ]]))
;

// after
$envelope = (new Envelope($message))
    ->with((new TransportConfiguration())->setDeliveryDelay(10000))
;

Thanks!

devrck commented 5 years ago

Seems like a nice addition to the project but looks like its more aimed at AMQP then the generic Message.

weaverryan commented 5 years ago

Yea, I was trying to list some of the most common "options" that you would need. But some won't be supported by your specific transport, and there may be other options that are on your Message class that we don't have helper methods for here (but you can still add it via metadata). It's kind of an imperfect "cover the most common cases" attempt. Fortunately, the error is quite good if you try to set any metadata but your Message class does not have a corresponding setter method for that.

drgomesp commented 5 years ago

Thanks, @weaverryan. Shall we get this merged?