1. Go to this page and download the library: Download snailweb/kubemq 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/ */
snailweb / kubemq example snippets
$queue = new \Snailweb\KubeMQ\Queue('kubemq-host', 9090, 'ClientA', 'Channel');
$message = new \Snailweb\KubeMQ\Message(
'metadata', // metadata (could be anything: int, string, array, object ...)
['field1' => 4, 'field2' => 'info'] // body (could be anything: int, string, array, object ...)
);
// Optional settings here
$message->setExpirationSeconds(5)
->setDelaySeconds(5)
->setMaxReceiveCount(10)
->setMaxReceiveQueue('queue-name');
try {
$queue->send($message);
} catch(Exception $exception) {
var_dump($exception);
}
$queue = new \Snailweb\KubeMQ\Queue('kubemq-host', 9090, 'ClientB', 'Channel',
32, // optional default max receive msg for this client
1); // optional default waiting time for this client
try {
$messages = $queue->receive(32, 1); // optional: we can override defaults of this client
if(!empty($messages)) {
var_dump($messages);
} else { echo "no messages\n"; }
} catch(Exception $exception) {
var_dump($exception);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.