I'm trying to implement a broker redelivery with ActiveMQ 5.8.0 and PHP Stomp extension. But this doesn't work as expected.
PHP subscriber that rollbacks messages
define('QUEUE_NAME', '/queue/Task.Test');
$stomp = new Stomp();
$stomp->subscribe(QUEUE_NAME, array(
'activemq.prefetchSize' => 10,
));
while (true) {
$tid = uniqid('tid');
$stomp->begin($tid);
try {
$frame = $stomp->readFrame();
if ($frame) {
print_r($frame->headers);
$stomp->ack($frame->headers['message-id'], array('transaction' => $tid));
echo "Get message {$frame->headers['message-id']}, rollback it", PHP_EOL;
$stomp->abort($tid);
} else {
$stomp->commit($tid);
}
} catch (StompException $e) {
$stomp->abort($tid);
}
}
ActiveMQ config (scheduler is enabled):
<plugins>
<redeliveryPlugin fallbackToDeadLetter="true" sendToDlqIfMaxRetriesExceeded="true">
<redeliveryPolicyMap>
<redeliveryPolicyMap>
<redeliveryPolicyEntries>
<!-- a destination specific policy -->
<redeliveryPolicy queue=">" maximumRedeliveries="2" redeliveryDelay="10000" />
</redeliveryPolicyEntries>
<!-- the fallback policy for all other destinations -->
<defaultEntry>
<redeliveryPolicy maximumRedeliveries="2" initialRedeliveryDelay="5000" redeliveryDelay="10000" />
</defaultEntry>
</redeliveryPolicyMap>
</redeliveryPolicyMap>
</redeliveryPlugin>
</plugins>
With that config subscriber receives all mesages and rollbacks them, so they returned to the queue, but I want them to be redelivered after some delay. There is special status for ACK: "poison ack" but I don't know how to specify it.
How can I enable redelivery on the broker side?