first commit
This commit is contained in:
33
producer.php
Normal file
33
producer.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Pheanstalk\Pheanstalk;
|
||||
|
||||
$pheanstalk = Pheanstalk::create('127.0.0.1');
|
||||
|
||||
$start = microtime(true);
|
||||
for ($i = 0; $i < 100000; $i++) {
|
||||
$msg = "id: " . $i . ' date: ' . date('Y-m-d H:i:s') . ' ' . json_encode($_SERVER);
|
||||
$msg = json_encode(['id' => $i, 'date' => date('Y-m-d H:i:s'), 'server' => $_SERVER]);
|
||||
|
||||
$pheanstalk
|
||||
->useTube('ExampleTube')
|
||||
->put($msg);
|
||||
|
||||
echo 'Added: ' . $i . PHP_EOL;
|
||||
|
||||
if (((microtime(true) - $start) * 1000) >= 1000) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// with some settings
|
||||
//$pheanstalk
|
||||
// ->useTube('testtube')
|
||||
// ->put(
|
||||
// json_encode(['test' => 'data']), // encode data in payload
|
||||
// Pheanstalk::DEFAULT_PRIORITY, // default priority
|
||||
// 30, // delay by 30s
|
||||
// 60 // beanstalk will retry job after 60s
|
||||
// );
|
||||
Reference in New Issue
Block a user