Skip to content

Add persistent functionality #7

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 4 commits into from
Mar 29, 2018

Conversation

darkin1
Copy link
Contributor

@darkin1 darkin1 commented Mar 20, 2018

RabbitMQ has persistent message functionality that has not been serviced.
To use it, just add to your app/Jobs/SomeJob.php field $persistent = true. After that when you restart RabbitMQ message still be in a queue.

@darkin1 darkin1 changed the title Add persisten functionality Add persistent functionality Mar 21, 2018
@makasim
Copy link
Member

makasim commented Mar 27, 2018

I think it would be better to always use persistent queues for AMQP\RabbitMQ transports.

Something like this would be great:

<?php

use Interop\Amqp\AmqpMessage;

if ($message instanceof AmqpMessage) {
  $message->setDeliveryMode(AmqpMessage::DELIVERY_MODE_PERSISTENT);
}

@darkin1
Copy link
Contributor Author

darkin1 commented Mar 29, 2018

Updated, please check

src/Queue.php Outdated
@@ -56,9 +56,15 @@ public function push($job, $data = '', $queue = null)
*/
public function pushRaw($payload, $queue = null, array $options = [])
{
$message = $this->psrContext->createMessage($payload);

if ($message instanceof \Interop\Amqp\Impl\AmqpMessage) {
Copy link
Member

Choose a reason for hiding this comment

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

could you import namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For interface \Interop\Amqp\AmqpMessage or implementation Interop\Amqp\AmqpMessage?
We can't use both or I could use an alias. Which you prefer?

Copy link
Member

Choose a reason for hiding this comment

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

use Interop\Amqp\AmqpMessage;

if ($message instanceof AmqpMessage) {

@makasim makasim merged commit 55be581 into php-enqueue:master Mar 29, 2018
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