2
2
3
3
namespace Enqueue \Symfony \Client ;
4
4
5
+ use Enqueue \Client \Message ;
5
6
use Enqueue \Client \ProducerInterface ;
6
7
use Psr \Container \ContainerInterface ;
7
8
use Psr \Container \NotFoundExceptionInterface ;
@@ -44,6 +45,7 @@ protected function configure(): void
44
45
$ this
45
46
->setDescription ('Sends an event to the topic ' )
46
47
->addArgument ('message ' , InputArgument::REQUIRED , 'A message ' )
48
+ ->addOption ('header ' , null , InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY , 'The message headers ' )
47
49
->addOption ('client ' , 'c ' , InputOption::VALUE_OPTIONAL , 'The client to consume messages from. ' , $ this ->defaultClient )
48
50
->addOption ('topic ' , null , InputOption::VALUE_OPTIONAL , 'The topic to send a message to ' )
49
51
->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
55
57
$ topic = $ input ->getOption ('topic ' );
56
58
$ command = $ input ->getOption ('command ' );
57
59
$ message = $ input ->getArgument ('message ' );
60
+ $ headers = $ input ->getOption ('header ' );
58
61
$ client = $ input ->getOption ('client ' );
59
62
60
63
if ($ topic && $ command ) {
@@ -68,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
68
71
}
69
72
70
73
if ($ topic ) {
71
- $ producer ->sendEvent ($ topic , $ message );
74
+ $ producer ->sendEvent ($ topic , new Message ( $ message, [], $ headers ) );
72
75
73
76
$ output ->writeln ('An event is sent ' );
74
77
} elseif ($ command ) {
0 commit comments