22
33namespace Enqueue \Symfony \Client ;
44
5+ use Enqueue \Client \Message ;
56use Enqueue \Client \ProducerInterface ;
67use Psr \Container \ContainerInterface ;
78use Psr \Container \NotFoundExceptionInterface ;
@@ -44,6 +45,7 @@ protected function configure(): void
4445 $ this
4546 ->setDescription ('Sends an event to the topic ' )
4647 ->addArgument ('message ' , InputArgument::REQUIRED , 'A message ' )
48+ ->addOption ('header ' , null , InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY , 'The message headers ' )
4749 ->addOption ('client ' , 'c ' , InputOption::VALUE_OPTIONAL , 'The client to consume messages from. ' , $ this ->defaultClient )
4850 ->addOption ('topic ' , null , InputOption::VALUE_OPTIONAL , 'The topic to send a message to ' )
4951 ->addOption ('command ' , null , InputOption::VALUE_OPTIONAL , 'The command to send a message to ' )
@@ -55,6 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
5557 $ topic = $ input ->getOption ('topic ' );
5658 $ command = $ input ->getOption ('command ' );
5759 $ message = $ input ->getArgument ('message ' );
60+ $ headers = $ input ->getOption ('header ' );
5861 $ client = $ input ->getOption ('client ' );
5962
6063 if ($ topic && $ command ) {
@@ -68,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
6871 }
6972
7073 if ($ topic ) {
71- $ producer ->sendEvent ($ topic , $ message );
74+ $ producer ->sendEvent ($ topic , new Message ( $ message, [], $ headers ) );
7275
7376 $ output ->writeln ('An event is sent ' );
7477 } elseif ($ command ) {
0 commit comments