1. Go to this page and download the library: Download coinvestor/laravel-batchsqs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use \CoInvestor\BatchSQS\Queues\Events\BatchMessageReleasingEvent;
class BatchMessageReleasingEventListener
{
public function handle(BatchMessageReleasingEvent $event)
{
$return = [];
// If the message is 'foo' it should be changed to 'foobar'
if ($event->message['MessageBody'] == 'foo') {
$return['MessageBody'] = 'foobar';
}
// If the queue name ends in .norbert, the message should have a message group id consisting of 128 '1's
if (preg_match('/.*\.norbert/', $event->queue)) {
$return['MessageGroupId'] = str_repeat("1", 128);
}
return $return;
}
}
use Illuminate\Support\Facades\Queue;
// Send all message batches to their respective queues
Queue::flush();
// Discard all message batches
Queue::flush(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.