Skip to content

Commit 2d439c5

Browse files
committed
Add header support
1 parent 97e2f99 commit 2d439c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/enqueue/Symfony/Client/ProduceCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Enqueue\Symfony\Client;
44

5+
use Enqueue\Client\Message;
56
use Enqueue\Client\ProducerInterface;
67
use Psr\Container\ContainerInterface;
78
use 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

Comments
 (0)