Skip to content

Implement DeliveryDelay, Priority and TimeToLive in PheanstalkProducer #1033

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

Merged
merged 2 commits into from
Mar 20, 2020
Merged

Implement DeliveryDelay, Priority and TimeToLive in PheanstalkProducer #1033

merged 2 commits into from
Mar 20, 2020

Conversation

likeuntomurphy
Copy link
Contributor

I could not take advantage of the MultiplierRetryStrategy built in to the Symfony Messenger component, because the Pheanstalk producer did not fully implement the setDeliveryDelay method (see also #821). Even though I only needed the delay, I went ahead and fully implemented the priority and time to live functionality of the Producer interface as well.

The code changes in the PR essentially do three things:

  1. ensures that “delivery delay” and “time to live” are set as milliseconds on the producer but passed to the transport as seconds;
  2. ensures that the respective message values are used when priority, delay or TTL is null; and
  3. ensures that any producer values do not persist for more than one send.

Each of these points has test coverage.

@makasim
Copy link
Member

makasim commented Mar 20, 2020

Thank you for the contribution @likeuntomurphy.

ensures that any producer values do not persist for more than one send.

That's not true. In fact, the producer should use the values for all messages that go through it. That's home JMS defines it and other Enqueue transports work.

If you need a one-time delay you should set it on the message or create a producer just for one send. That's ok, producer meant to be lightweight objects.

Don’t reset producer values after send
@likeuntomurphy
Copy link
Contributor Author

Thanks for the feedback, @makasim.

I realized that the enqueue transport will set the values on the producer for each send as long as the values are configured as options (https://github.com/sroze/messenger-enqueue-transport/blob/master/QueueInteropTransport.php#L140). So I removed the code that was resetting the values after each send.

And I was also wrong about how to prioritize the values. I copied a block of code from the Mongo producer and modified it for Beanstalk, and I updated the tests accordingly.

@makasim makasim merged commit a99805a into php-enqueue:master Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants