composer require viloveul/transport
initilize bus connection for data transport
require_once __DIR__ . '/vendor/autoload.php';
$bus = new Viloveul\Transport\Bus();
$bus->initialize();
$bus->addConnection('amqp://localhost:5672//');
declaring class passenger (for whatever your data)
use Viloveul\Transport\Passenger;
class TaskPassenger extends Passenger
{
public function point(): string
{
return 'exchange name';
}
public function route(): string
{
return 'routing.key';
}
public function data(): string
{
return 'string-data';
}
public function handle(): void
{
$this->setAttribute('data', [
'foo' => 'bar'
]);
}
}
run rabbit under docker
docker run --rm -p 5672:5672 rabbitmq:3
# rabbitmq listen for port 5672
processing task
$bus->process(new TaskPassenger);
cd sample/celery
celery -A tasks worker --loglevel=info
cd sample/socket.io
npm install
npm start