PHP code example of phpgears / cqrs-async-queue-interop

1. Go to this page and download the library: Download phpgears/cqrs-async-queue-interop 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/ */

    

phpgears / cqrs-async-queue-interop example snippets




use Gears\CQRS\Async\AsyncCommandBus;
use Gears\CQRS\Async\QueueInterop\QueueInteropCommandQueue;
use Gears\CQRS\Async\Serializer\JsonCommandSerializer;
use Gears\CQRS\Async\Discriminator\ParameterCommandDiscriminator;

/* @var \Gears\CQRS\CommandBus $commandBus */
/* @var \Interop\Queue\PsrContext $context */
/* @var \Interop\Queue\PsrDestination $destination */

$commandQueue = new QueueInteropCommandQueue(new JsonCommandSerializer(), $context, $destination);

$asyncCommandBus new AsyncCommandBus(
    $commandBus,
    $commandQueue,
    new ParameterCommandDiscriminator('async')
);

$asyncCommand = new CustomCommand(['async' => true]);

$asyncCommandBus->handle($asyncCommand);