public function delayedPublish($delay, $msgBody, $routingKey = '', $additionalProperties = array())
 {
     if (!is_integer($delay) || $delay < 0) {
         throw new \UnexpectedValueException('Publish delay should be a positive integer.');
     }
     # expire the queue a little bit after the delay, but minimum 1 second
     $expiration = 1000 + floor(1.1 * $delay);
     $name = sprintf('%s-exchange', $this->prefix);
     $id = sprintf('%s-waiting-queue-%s-%d', $this->prefix, $routingKey, $delay);
     $producer = new Producer($this->connection);
     $producer->setExchangeOptions(array('name' => $name, 'type' => 'direct'));
     $producer->setQueueOptions(array('name' => $id, 'routing_keys' => array($id), 'arguments' => array('x-message-ttl' => array('I', $delay), 'x-dead-letter-exchange' => array('S', $this->destination_exchange), 'x-dead-letter-routing-key' => array('S', $routingKey), 'x-expires' => array('I', $expiration))));
     $producer->setupFabric();
     $producer->publish($msgBody, $id, $additionalProperties);
 }
 private function loadProducers($app)
 {
     $app['rabbit.producer'] = $app->share(function ($app) {
         if (!isset($app['rabbit.producers'])) {
             return;
         }
         $producers = [];
         foreach ($app['rabbit.producers'] as $name => $options) {
             $connection = $this->getConnection($app, $options, $app['rabbit.connections']);
             $producer = new Producer($connection);
             $producer->setExchangeOptions($options['exchange_options']);
             if (isset($options['queue_options'])) {
                 $producer->setQueueOptions($options['queue_options']);
             }
             if (array_key_exists('auto_setup_fabric', $options) && !$options['auto_setup_fabric']) {
                 $producer->disableAutoSetupFabric();
             }
             $producers[$name] = $producer;
         }
         return $producers;
     });
 }