Created
July 23, 2018 09:45
-
-
Save JusteLeblanc/33a877e5e0d49e8a38e5d7a9adf30338 to your computer and use it in GitHub Desktop.
Elements to configure RabbitMQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Installation of rabbitmq-cli-consumer | |
To read before the installation: https://github.com/corvus-ch/rabbitmq-cli-consumer | |
On the server install rabbitmq-cli-consumer | |
mkdir -p rabbitmq-cli-consumer | |
cd rabbitmq-cli-consumer/ && wget https://github.com/corvus-ch/rabbitmq-cli-consumer/releases/download/2.2.0/rabbitmq-cli-consumer_2.2.0_linux_amd64.tar.gz | |
tar xfzv rabbitmq-cli-consumer_2.2.0_linux_amd64.tar.gz | |
sudo mv rabbitmq-cli-consumer /usr/local/bin/ | |
rm * | |
Run rabbitmq-cli-consumer specifying the command you've just created | |
rabbitmq-cli-consumer -V -u "amqp://dev:dev@localhost" -e "symfony/bin/console <YOUR_CONSUMER_COMMAND>" -q <YOUR_PRODUCER_NAME> | |
Access to RabbitMQAdmin interface to check if messages are well-processed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
old_sound_rabbit_mq: | |
connections: | |
default: | |
host: '%rabbitmq_host%' | |
user: '%rabbitmq_user%' | |
password: '%rabbitmq_password%' | |
vhost: '%rabbitmq_vhost%' | |
producers: | |
<PRODUCER_NAME>: | |
connection: default | |
exchange_options: | |
name: <PRODUCER_NAME> | |
type: direct | |
queue_options: | |
name: <PRODUCER_NAME> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class NewController extends Controller | |
{ | |
public function indexAction(Request $request) | |
{ | |
... | |
$this->get('old_sound_rabbit_mq.<PRODUCER_NAME>_producer')->publish(<UNIQ_MESSAGE_ID>); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Command; | |
use AssuranceVieBundle\Entity\Subscription; | |
use AssuranceVieBundle\Generator\PdfGenerator; | |
use AssuranceVieBundle\Manager\SubscriptionManager; | |
use AssuranceVieBundle\Service\Mailer; | |
use Doctrine\ORM\EntityRepository; | |
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
/** | |
* Class YourConsumerCommand | |
*/ | |
class YourConsumerCommand extends ContainerAwareCommand | |
{ | |
/** | |
* | |
*/ | |
protected function configure() | |
{ | |
$this | |
->setName('<YOUR_CONSUMER_COMMAND_NAME>') | |
->addArgument('event', InputArgument::REQUIRED); | |
} | |
/** | |
* @param InputInterface $input | |
* @param OutputInterface $output | |
* | |
* @return int|null|void | |
*/ | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
... | |
try { | |
... | |
} catch (\Exception $e) { | |
$logger = $this->getContainer()->get('logger'); | |
$logger->error($e->getMessage()); | |
... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment