PHP code example of tourze / async-service-call-bundle
1. Go to this page and download the library: Download tourze/async-service-call-bundle 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/ */
tourze / async-service-call-bundle example snippets
use Tourze\AsyncServiceCallBundle\Message\ServiceCallMessage;
$message = new ServiceCallMessage();
$message->setServiceId('my.service.id');
$message->setMethod('processData');
$message->setParams(['param1', 'param2']);
$message->setMaxRetryCount(3);
$message->setRetryCount(3);
// Dispatch to message queue
$messageBus->dispatch($message);
use Tourze\AsyncServiceCallBundle\Message\ServiceCallMessage;
use Symfony\Component\Messenger\MessageBusInterface;
class MyController
{
public function __construct(
private MessageBusInterface $messageBus
) {}
public function sendAsyncCall(): void
{
$message = new ServiceCallMessage();
$message->setServiceId('email.service');
$message->setMethod('sendEmail');
$message->setParams(['[email protected]', 'Subject', 'Body']);
$message->setMaxRetryCount(5);
$message->setRetryCount(5);
$this->messageBus->dispatch($message);
}
}