/** * {@inheritdoc} */ public function produce($payload, $configs = []) { $configs = new Dictionary($configs); $this->producers->each(function (ProducerInterface $producer) use($payload, $configs) { /** @var MapInterface $brokerConfigs */ $brokerConfigs = $configs->get($producer->getName()); try { $topic = $brokerConfigs->get('topic'); } catch (\OutOfBoundsException $e) { throw new \InvalidArgumentException('You should configure the topic/exchange that you want to produce to'); } $producer->produce($topic, $payload, $brokerConfigs); }); }
/** * Configure the producer * * @param $topic * @param VectorInterface $channels * @param MapInterface $configs */ protected function configureChannels($topic, VectorInterface $channels, MapInterface $configs) { $channels->each(function (AMQPChannel $channel) use($topic, $configs) { $channel->queue_declare($topic, $configs->get('passive'), $configs->get('durable'), $configs->get('exclusive'), $configs->get('auto_delete'), $configs->get('nowait'), $configs->get('arguments'), $configs->get('ticket')); }); $this->configured = true; }