graze / queue

:postbox: Flexible abstraction for working with queues in PHP.
MIT License
49 stars 10 forks source link

Allow for setting `DelaySeconds` on a per-message basis #34

Closed bjornpost closed 8 years ago

bjornpost commented 8 years ago

According to the docs this is possible by providing a DelaySeconds argument for each Entry. If I'm understanding things correctly, graze/queue currently only allows for settings the DelaySeconds parameter for the entire queue, not message.

To change that (for SqsAdapter, I guess this is n/a to the ArrayAdapter):

https://github.com/graze/queue/blob/master/src/Adapter/SqsAdapter.php#L236-L239

$message = [    
  'Id' => $id,    
  'DelaySeconds' => $metadata->get('DelaySeconds'),    
  ...
];

Usage:

$this->client->create(.., [ 'metadata' => [ 'DelaySeconds' => 10, ], ])

I can prepare a PR if this is the way to go to implement such a feature.

Cheers, Bjorn

P.s. maybe I'm missing something, but should graze/queue be able to work with SQS death letter queues? How would I mark a message as 'unprocessable' (so SQS can move it to the dead letter queue?)

h-bragg commented 8 years ago

Hi,

Thanks for the suggestion!

That looks like the correct way to implement it, create a PR and I will have a look.

From a brief scan of the docs I can't see a way of marking a particular message as un-processable to automatically get put on a dead letter queue from within SQS. The standard way SQS deals with it is by marking the number of times a message has been attempted.

The alternative is to manage it within this client, which is something we will think about.

h-bragg commented 8 years ago

Merged into master.