Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.24 KB | None | 0 0
  1.         $channel = null;
  2.         return $this->client
  3.             ->connect()
  4.             ->then(
  5.                 function(Client $client) {
  6.                     return $client
  7.                         ->channel();
  8.                 })
  9.             ->then(
  10.                 function(Channel $receivedChannel) use (&$channel)
  11.                 {
  12.                     $channel = $receivedChannel;
  13.                     return $receivedChannel
  14.                         ->qos(
  15.                             $this->configuration->getQosConfig()->get('pre_fetch_size'),
  16.                             $this->configuration->getQosConfig()->get('pre_fetch_count'),
  17.                             $this->configuration->getQosConfig()->get('global')
  18.                         );
  19.                        
  20.                 }
  21.             )
  22.             ->then(
  23.                 function() use ($clients, $entryPointName, $clients, $channel)
  24.                 {
  25.                     return $channel
  26.                         /** Application main exchange */
  27.                         ->exchangeDeclare($entryPointName, self::EXCHANGE_TYPE_DIRECT);
  28.                         /** Events exchanges */
  29.  
  30.                 }
  31.             )->then(
  32.                 function() use ($channel, $entryPointName)
  33.                 {
  34.                     return $channel
  35.                         ->exchangeDeclare(
  36.                             \sprintf('%s.events', $entryPointName),
  37.                             self::EXCHANGE_TYPE_DIRECT
  38.                         );
  39.                 }
  40.             )
  41.             /** Messages (internal usage) queue */
  42.             ->then(
  43.                 function() use ($channel, $entryPointName)
  44.                 {
  45.                     return $channel->queueDeclare(
  46.                         \sprintf('%s.messages', $entryPointName),
  47.                         false, true
  48.                     );
  49.                 }
  50.             )
  51.             /** Configure routing keys for clients */
  52.             ->then(
  53.                 function(MethodQueueDeclareOkFrame $frame) use (
  54.                     $channel, $clients, $entryPointName
  55.                 )
  56.                 {
  57.                     $promises = \array_map(
  58.                         function($routingKey) use ($frame, $channel, $entryPointName)
  59.                         {
  60.                             return $channel->queueBind(
  61.                                 $frame->queue,
  62.                                 $entryPointName,
  63.                                 $routingKey
  64.                             );
  65.                         },
  66.                         $clients
  67.                     );
  68.                     return \React\Promise\all($promises)
  69.                         ->then(
  70.                             function() use ($frame)
  71.                             {
  72.                                 return $frame;
  73.                             }
  74.                         );
  75.                 }
  76.             )
  77.             ->then(
  78.                 function(MethodQueueDeclareOkFrame $frame) use ($channel)
  79.                 {
  80.                     $this->logger->info('RabbitMQ subscription started');
  81.                     return RabbitMqChannelData::create($channel, $frame->queue);
  82.                 },
  83.                 $this->onFailedCallable
  84.             );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement