PHP code example of becklyn / messaging

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

    

becklyn / messaging example snippets


$builder = new SymfonyJsonSerializedMessageBuilder($serializer);
$message = $builder->build("content", "destination");

$publisher = new Publisher($connection, $serializer);
$publisher->publish($message);

class SampleWorker implements Worker
{
    public function execute(Message $message) : void
    {
        // TODO: Process the received message ...
        \var_dump($message);
    }
}

$queue = new QueueDefinition("destination");
$params = new ConsumerParams();

$consumer = new Consumer($connection, $serializer, $lifecycleManager);
$consumer->consume(new SampleWorker(), $queue, $params);