PHP code example of inteve / message-queue

1. Go to this page and download the library: Download inteve/message-queue 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/ */

    

inteve / message-queue example snippets

 php
$exceptionHandler = function (\Throwable $e) {
	\Tracy\Debugger::log($e, \Tracy\Debugger::EXCEPTION);
};
$dateTimeFactory = new MyDateTimeFactory; // implementation of Phig\DateTimeFactory
$adapter = new MemoryAdapter($exceptionHandler);
$manager = new Manager($adapter, $dateTimeFactory);
 php
$manager->fetch(
	queue: 'name-of-queue',
	handler: function (array $data) {
		$data['field'];
		$data['field2'];
	}
);
 php
$message = $manager->multiFetch(
	handlers: [
		'name-of-queue' => function (array $data) {
			$data['field'];
			$data['field2'];
		}
		'name-of-queue-B' => function (array $data) {
			$data['field'];
			$data['field2'];
		}
	],
	limit: 10 // number of messages processed in multiFetch() call
);
 php
$message = $manager->multiFetch(
	handlers: [
		'name-of-queue' => function (array $data) {
			$data['field'];
			$data['field2'];
		}
		'name-of-queue-B' => function (array $data) {
			$data['field'];
			$data['field2'];
		}
	],
	limit: 10, // number of messages processed in multiFetch() call
	fetchFrom: $mananger::FROM_LISTED_ONLY
);