Skip to content
Snippets Groups Projects
Commit e3a38a54 authored by Maxime Veber's avatar Maxime Veber
Browse files

add stuff

parent 2ecba8b6
No related branches found
No related tags found
No related merge requests found
Pipeline #1742 failed with stages
in 8 minutes and 56 seconds
......@@ -17,3 +17,10 @@
APP_ENV=dev
APP_SECRET=a19f0835963f9d59bd9c986b287e9fa3
###< symfony/framework-bundle ###
###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=doctrine://default
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
###< symfony/messenger ###
......@@ -4,17 +4,17 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.2.5",
"php": ">=8.0.0",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/console": "5.2.*",
"symfony/dotenv": "5.2.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.2.*",
"symfony/maker-bundle": "^1.31",
"symfony/messenger": "5.2.*",
"symfony/yaml": "5.2.*"
},
"require-dev": {
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
......
This diff is collapsed.
......@@ -2,4 +2,5 @@
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
];
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
routing:
# Route your messages to the transports
'App\Message\PerfTestMessage': async
<?php
namespace App\Command;
use App\Message\PerfTestMessage;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\MessageBusInterface;
class GenMessagesCommand extends Command
{
protected static $defaultName = 'app:gen-messages';
protected static $defaultDescription = 'Messages messages messages';
/**
* GenMessagesCommand constructor.
*/
public function __construct(private MessageBusInterface $bus, string $name = null) {
parent::__construct($name);
}
protected function configure(): void
{
$this
->setDescription(self::$defaultDescription)
->addArgument('nb', InputArgument::OPTIONAL, 'Numbers of messages', 10000)
// ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$number = (int) $input->getArgument('nb');
//
// if ($arg1) {
// $io->note(sprintf('You passed an argument: %s', $arg1));
// }
//
// if ($input->getOption('option1')) {
// // ...
// }
for($i = 0; $i < $number; $i++) {
$this->bus->dispatch(new PerfTestMessage());
}
$io->success("Sended $number messages.");
return Command::SUCCESS;
}
}
<?php
namespace App\Message;
final class PerfTestMessage
{
/*
* Add whatever properties & methods you need to hold the
* data for this message class.
*/
// private $name;
//
// public function __construct(string $name)
// {
// $this->name = $name;
// }
//
// public function getName(): string
// {
// return $this->name;
// }
}
<?php
namespace App\MessageHandler;
use App\Message\PerfTestMessage;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
final class PerfTestMessageHandler implements MessageHandlerInterface
{
public function __invoke(PerfTestMessage $message)
{
// Doing nothing.
}
}
{
"doctrine/inflector": {
"version": "2.0.3"
},
"nikic/php-parser": {
"version": "v4.10.5"
},
"psr/cache": {
"version": "2.0.0"
},
......@@ -11,6 +17,9 @@
"psr/log": {
"version": "1.1.4"
},
"symfony/amqp-messenger": {
"version": "v5.2.7"
},
"symfony/cache": {
"version": "v5.2.7"
},
......@@ -38,6 +47,9 @@
"symfony/deprecation-contracts": {
"version": "v2.4.0"
},
"symfony/doctrine-messenger": {
"version": "v5.2.7"
},
"symfony/dotenv": {
"version": "v5.2.4"
},
......@@ -97,6 +109,27 @@
"symfony/http-kernel": {
"version": "v5.2.7"
},
"symfony/maker-bundle": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/messenger": {
"version": "4.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.3",
"ref": "e9a414b113ceadbf4e52abe37bf8f1b443f06ccb"
},
"files": [
"config/packages/messenger.yaml"
]
},
"symfony/polyfill-intl-grapheme": {
"version": "v1.22.1"
},
......@@ -112,6 +145,9 @@
"symfony/polyfill-php80": {
"version": "v1.22.1"
},
"symfony/redis-messenger": {
"version": "v5.2.7"
},
"symfony/routing": {
"version": "5.1",
"recipe": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment