daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function actionIndex()
  2.     {
  3.         $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
  4.         $channel = $connection->channel();
  5.  
  6.         $channel->queue_declare('calllist', false, false, false, false);
  7.         $channel->basic_consume('calllist', '', false, true, false, false, function ($msg) {
  8.             $message = json_decode($msg->body);
  9.             /**
  10.              * @var CampaignList $campaignList
  11.              * @var CampaignProcess $process
  12.              */
  13.             $campaignList = CampaignList::find()->where(['id' => $message->campaign_list_id])->one();
  14.             if ($campaignList !== null) {
  15.                 try {
  16.                     $preparer = Preparer::create($campaignList);
  17.                     $statusData = $preparer->prepare();
  18.                     $process = $campaignList->getProcess();
  19.                     $process->updateStatus($statusData);
  20.                 } catch (Throwable $e) {
  21.                     $domain = $campaignList->getCampaign()->getDomain();
  22.                     $logger = new Logger('calllist');
  23.                     $logger->pushHandler(
  24.                         new StreamHandler(Yii::$app->params['app_dir'] . '/../logs/command/' . $domain->getName() . '.log', Logger::ERROR)
  25.                     );
  26.                     $logger->error('CampaignList(' . $message->campaign_list_id . ') ' . get_class($e) . ' - message -> ' . $e->getMessage());
  27.                     $logger->error('CampaignList(' . $message->campaign_list_id . ') ' . get_class($e) . ' - trace -> ' . $e->getTraceAsString());
  28.  
  29.                     Crier::run(
  30.                         'ERROR IN CALL LIST SERVICE' . PHP_EOL . PHP_EOL .
  31.                         'Domain: ' . $domain->name . PHP_EOL .
  32.                         'campaign_list_id: ' . $campaignList->getId() . PHP_EOL .
  33.                         'Message: ' . $e->getMessage() . PHP_EOL .
  34.                         'Trace:' . PHP_EOL . PHP_EOL . $e->getTraceAsString()
  35.                     );
  36.                 }
  37.             }
  38.         });
  39.  
  40.         while (count($channel->callbacks)) {
  41.             $channel->wait();
  42.         }
  43.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top